I am testing a prototype of a method in the Chrome console and getting an unexpected result regarding Array.prototype.reduce ()
For example, for an example below
let a = [["a",1],["b",1],["c",1]];
let result = a.reduce((acc, e) => acc[e[0]]=e[1], {});
the result that I expected would be
{
"a": 1,
"b": 1,
"c": 1
}
but instead I get a value of 1
source
share