codewars-js练习
2021/6/1
github 地址
【1】<8kyu>【Remove First and Last Character】
example:
abcd --> bc
solution
function removeChar(str) {
return str.slice(1, -1);
}
【2】<7kyu>【Powers of i】
i is the imaginary unit, it is defined by i² = -1, therefore it is a solution to x²+1=0.
example:
pofi(0),'1'
pofi(1),'i'
pofi(2),'-1'
pofi(3),'-i'
pofi(4),'1'
pofi(5),'i'
solution
function pofi(n){
return ["1","i","-1","-i"][n%4];
}
224

被折叠的 条评论
为什么被折叠?



