Reversing Fun
This commit is contained in:
12
reversing-fun/index.js
Normal file
12
reversing-fun/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// https://www.codewars.com/kata/reversing-fun/javascript
|
||||
|
||||
function flipNumber(n) {
|
||||
let cnt = 0;
|
||||
const arr = [...n];
|
||||
const res = [];
|
||||
while (1) {
|
||||
let c = arr[++cnt % 2 ? 'pop' : 'shift']();
|
||||
if (!c) return res.join``;
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user