JavaScript arrayToList

前端 未结 2 1027
失恋的感觉
失恋的感觉 2021-01-28 19:28

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.

2条回答
  •  感动是毒
    2021-01-28 19:39

    You may try this as well :

        
        
        function arrayToList(arrayx){ 
        for(var i = arrayx[0];i < Math.max.apply(Math,arrayx); i+=arrayx[0])
        {
         var list = {
         value: i,
         rest: {
         value: i+=10,
         rest: null
           }
          }
        return list;
        }
        }
        
        console.log(arrayToList([10 , 20]));

提交回复
热议问题