Convert array to list in javascript
function array_to_list(arr) { list = null for (i = arr.length; i >= 0; i--) { list = { value: arr[i], rest: list }; } return list; } x = array_to_list([10, 20]); console.log(JSON.stringify(x)); the output I get is : {"value":10,"rest":{"value":20,"rest":{"rest":null}}} but…