two js questions
来源:互联网 发布:protobuf java 编辑:程序博客网 时间:2024/06/10 09:15
1.
It's pretty straightforward.Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, except in C, where, to keep the difficulty at the level of the kata, you are given two parameters, the first a buffer with length exactly the same as the second parameter, the original string. You don't have to worry with strings with less than two characters.
代码:
function removeChar(str) { return str.slice(1, -1);}
2
#Find the missing letterWrite a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.You will always get an valid array. And it will be always exactly one letter be missing. The length of the array will always be at least 2.The array will always contain letters in only one case.Example:['a','b','c','d','f'] -> 'e'['O','Q','R','S'] -> 'P'(Use the English alphabet with 26 letters!)Have fun coding it and please don't forget to vote and rank this kata! :-)I have also created other katas. Take a look if you enjoyed this kata!
代码:
function findMissingLetter(array) { var str = array.join(""); for (var i = 0, l = str.length,r=""; i < l; i++) { if (str.charCodeAt(i+1) - str.charCodeAt(i)!= 1) { return String.fromCharCode(str.charCodeAt(i)+1) } }}
阅读全文
0 0
- two js questions
- Two Minor Questions
- Leetcode Two Maximum Subarray Questions
- Questions
- Questions
- questions
- Questions
- Questions
- questions
- Questions
- questions
- questions
- questions
- questions
- questions
- questions
- QUESTIONS
- Two Interview questions! about event and Observer mode
- 将本地jar添加到Maven仓库
- SSD模型分析
- MySQL--插入记录--insert
- activiti实战二(请假bpmn)
- Linux修改用户目录
- two js questions
- View添加手势,防止View上点击其他视图触发点击效果
- 知识、见识和认知
- 51 nod 1421 最大mod值 思维题
- 通过npm写一个cli命令行工具
- 15年编程生涯,资深架构师总结的7条经验
- express路由模块化
- 优秀代码注释的5个技巧
- 【小程序】调用wx.request接口时需要注意的几个问题