I have an array:
[ [ \'cardType\', \'iDEBIT\' ],
[ \'txnAmount\', \'17.64\' ],
[ \'txnId\', \'20181\' ],
[ \'txnType\', \'Purchase\' ],
[ \'txnDate\
When I used the reduce function with acc[i] = cur;
it returned a kind of object that I needed to access it like a array using this way obj[i].property
. But using this way I have the Object that I wanted and I now can access it like obj.property
.
function convertArraytoObject(arr) {
var obj = arr.reduce(function (acc, cur, i) {
acc = cur;
return acc;
}, {});
return obj;
}