Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var arrayToList = function(array) {
// Base case.
if (array.length == 0) {
return null;
}
// Trasversal.
var _value = array[0];
array.shift();
return {
value: _value,
rest: arrayToList(array)
}
}
console.log(arrayToList([10, 20]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.