Tuesday, 1 September 2020

how to remove negative values from object using javascript or es6

What is the best way to check if an object has items with negative values using javascript or ES6, if that is the case remove it from the object?

foo = { 0: 0, 1: -1, 2: 2, 3: -1}

result should be the one below

foo = { 0: 0, 1: 2}

Sorry, i am coming from a python background but i would love to hear from you.



from how to remove negative values from object using javascript or es6

No comments:

Post a Comment