I have an array.
var nestedArr =[['loop0', 0], ['loop1', 1], ['loop2', 2], ['loop3', 3], ['loop4', 4], ['loop5', 5]]
I have to get using for loop this:
var obj = { loop0: 0, loop1: 1, loop2: 2 ...};
I am trying this :
for(var j = 0; j < nestedArr.length; j++){
obj[nestedArr[j][0]] = nestedArr[j][1]}
but I am getting values as undefined. How do I add values correctly.
var obj = {}
, the code works.