I have a Javascript map that I need to loop through, however the value of the map is an object which is an array. This is what I have so far;
Javascript to loop through map
var food = 'pizza'
var ten = 10
function logMapElements(value, key, map) {
console.log(`${key} = ${value}`);
}
new Map([['foo', 3], ['bar', {item:food, price:ten}]])
.forEach(logMapElements);
Actual Output;
> "foo = 3"
> "bar = [object Object]"
What I expected Output to look like;
> "foo = 3"
> "bar = [{item:pizza, price:10]"
What am I doing incorrectly that it does not show the actual object variables?
Thanks for any help!