can anyone help me figure what i did wrong in my code? Cause I wanna created a function which can help me turn all the array data into list and print the list out.
Original Instructions ****Write a function arrayToList that builds up a data structure like the previous one when given [1, 2, 3] as argument, and write a listToArray function that produces an array from a list. Also write the helper functions prepend, which takes an element and a list and creates a new list that adds the element to the front of the input list, and nth, which takes a list and a number and returns the element at the given position in the list, or undefined when there is no such element. If you haven’t already, also write a recursive version of nth.****
function arrayToList(arrayx){
for(var i=10;i<arrayx.length;i+=10)
var list = {
value: i,
rest: {
value: i+=10,
rest: null}}
return list;
}
The Results I wanna have is
console.log(arrayToList([10, 20]));
// → {value: 10, rest: {value: 20, rest: null}}