:)
I need to remove properties whose values are numbers greater than the given number. I've looked at this question: How do I remove a property from a JavaScript object? and this one: Remove some properties from array of javascript objects and this one: remove item from array javascript but I still cannot seem to get the desired answer I need. (They're either returning the numbers only or other parts of the array I don't need.)
This is the code I wrote:
function removeNumbersLargerThan(num, obj) {
arr = [];
for (var i = 0; i < obj.length; i++) {
return arr[i] > 5;
}
}
var obj = {
a: 8,
b: 2,
c: 'montana'
};
removeNumbersLargerThan(5, obj);
This is my result:
console.log(obj); // => { a: 8, b: 2, c: 'montana' }
The correct console.log should be this though:
{ b: 2, c: 'montana' }
Any advice? Thank you! PS: I'm new and my questions seem to be getting marked down a lot even though I'm trying to follow the rules. If I'm posting incorrectly could someone please let me know what I'm doing wrong if they're going to mark me down? This way I can improve. I'm here to learn! :D Thanks so much!