I’m wanting to go through the object and delete any even numbers, but I keep getting an error where I can’t do the following: if (obj[currentValue] % 2 =0)
. How can I fix this? Here’s my code:
var obj = {
a: 2,
b: 3,
c: 4
};
function removeEvenValues(obj) {
for (var currentValue in obj) {
if (obj[currentValue] % 2 = 0) {
delete obj[currentValue]
} else {
obj[currentValue]
}
}
}
removeEvenValues(obj);
console.log(obj); // --> { b: 3 }