I'm trying to delete the entry with key '1' in the map. Can anyone tell me why is map.delete(1) returning false and the entry is not being deleted.
let nums = [1,1,1,2,2,3]
let map = new Map();
for (let num of nums) {
if (num in map) {
map[num]++;
} else {
map[num] = 1;
}
}
console.log(map) // Map(0) { '1': 3, '2': 2, '3': 1, '4': 3 }
console.log(map.delete(1)); // false
console.log(map) // Map(0) { '1': 3, '2': 2, '3': 1, '4': 3 }
4keys since there are no4values in yournumsarray. Please provide a minimal reproducible example.