Last active
September 29, 2016 20:51
-
-
Save mckomo/b059372c034d73abe6bc97fb2c13059d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const list = ['m', 'c', 'k', 'o', 'm', 'o'] | |
const reverse = (list) => { | |
if (list.length == 0) return []; | |
let first = list.splice(0, 1); | |
return reverse(list).concat(first); | |
} | |
let result = reverse(list); | |
console.log(result); | |
// [ 'o', 'm', 'o', 'k', 'c', 'm' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment