Javascript hashmap

function zappa(nums) {
const mapObj = new Map();
for (let i = 0; i < nums.length; i++) {
mapObj.set(nums[i], i);
}
return mapObj;
}
console.log(zappa([2, 7, 11, 15]));
function zappa(nums) {
const mapObj = new Map();
for (let i = 0; i < nums.length; i++) {
mapObj.set(nums[i], i);
}
return mapObj;
}
console.log(zappa([2, 7, 11, 15]));
its showing empty Object in console. But when i do
return mapObj.size
//console logs 4
return mapObj.size
//console logs 4
4 Replies
MarkBoots
MarkBoots14mo ago
i can see
No description
MarkBoots
MarkBoots14mo ago
what browser/console do you use
JOY
JOYOP14mo ago
i was using codepen
MarkBoots
MarkBoots14mo ago
ah, yea. that doest show all
Want results from more Discord servers?
Add your server