Reversing Fun

This commit is contained in:
2019-11-11 20:53:28 +01:00
parent 67173a0f94
commit 52a13c7c81
2 changed files with 28 additions and 0 deletions

12
reversing-fun/index.js Normal file
View 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);
}
}