function createList(arr) {
if(!arr.length){
return {value:arr[0], rest: null};
}
else {
return {
value: arr[0] ,
rest: {
createList(arr.slice(1))
}
};
}
}
console.log(arrayToList([1,2,3]));
i'm working off chapter 4 from the eloquent javascript exercises and i can't seem to make this recursive list. It gives me a syntax error that the method "." call is a unexpected token
arrayToList? I assume you meant to callcreateList.arr[0]after specifically checking to see if the length is 0?