sorry, it's me again, I’d like to create a function whose name is “arrayToList”, however, I don’t know why it doesn’t work , and keeps showing “Unexpected token if”, can anyone help me?
Results I want is
console.log(arrayToList([10, 20])); // → {value: 10, rest: {value: 20, rest: null}}
However, it keeps showing “Uncaught SyntaxError: Unexpected token if (line 9)”
function arrayToList(arrayx){
for(var i=0;i<arrayx.length;i++)
var list={
value: array[i],
rest: {
value: array[i+1],
rest: null
}
};
return list;
}