Using this array-like object, I am attempting to obtain the index for each property. However, I am encountering an issue when trying to output the result by logging the object. Can you help me identify what I am doing wrong?
// Array-like object
var pickedCards = { 0: 'a', 1: 'b', 2: 'c' };
Object.getOwnPropertyNames(pickedCards).forEach(function(val) {
val++;
return pickedCards[val];
});
console.log(pickedCards);