I am working on a pre-BootCamp problem. I am taking an object and removing any properties that have odd numeric values, and then returning the object. Why are the odd values not being filtered out?
/*
Write a function called "removeOddValues".
Given an object, "removeOddValues" removes any properties whose valuse are odd numbers.
var obj = {
a: 2,
b: 3,
c: 4
};
removeOddValues(obj);
console.log(obj); // --> { a: 2, c: 4 }
*/
function removeOddValues(obj) {
for (var values in obj) {
if (obj[values] === 'Number' && obj[values] % 2 !== 0) {
delete obj[values]
}
}
return obj;
};
var obj = {
a: 2,
b: 3,
c: 4
};
removeOddValues(obj);
output:
{a: 2, b: 3, c: 4}