I have a map like this:
and I want to remove {frequency:"WN"}
from array inside map value.
I am trying to remove it this way but value isn't getting removed:
const map2 = new Map();
map2.set(0, [{frequency:"DN"},{frequency:"WN"}, {frequency:"KK"}]);
map2.set(1, [{frequency:"DN"},{frequency:"WN"}, {frequency:"KK"}]);
const strNanFrq = ['DN', 'WN', 'MN', 'QN', 'YN'];
for (tsRequest of map2.values()) {
tsRequest.filter((req, index) => {
if (strNanFrq.includes(req['frequency'])) {
tsRequest.splice(index, 1);
}
});
}
console.log(Array.from(map2.values())); // still has all the values in map