Converting an array into object

the reduce method gives to the callback two arguments, an accumulator that is updated each time with the value returned from the callback, and the current value being iterated over

incide the array there are other arrays, in these sub-arrays you have a string as first element and a number as second one
so if the subarray is ["PENNY", 0.17] inside the object there will be a key-value pair as "PENNY": 0.17
you are suggesting for the key-value pair to be 0.17: 0.17 which wouldn’t be much useful, would it?

1 Like