Good afternoon.
Tell on your toes, if not laziness - why add array element into the tree from the bottom up?
var arrayToList = function(array){ var list = null; for (i = array.length-1; i >= 0;i--){ list = {value:array[i], next:list}; console.log(array[i]); } return list; } console.log(arrayToList([10,20,30,40,50]));
can't understand the logic... the idea is have a top-down, i.e. the tree should be:
50
-40
--30
---20
----10
or is it because recursion works? If so, why?