cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Change certain values inside an Array

ionutbarna
New Contributor II

Hello,

I have this json:

{
        "a": "Hello Word",
        "b": 1,
        "c": "some",
        "d": 10,
        "nested": [{
            "m": "hey",
            "o": 10,
            "p": "hello",
            "q": 100
        }]
}

I am trying to multiply each number field by 10 and the output structure needs to be the same.
So far Iโ€™ve managed to get it worked for an Object using: $.mapValues((value, key) => !isNaN(value) ? value * 10 : value) but I donโ€™t really know how can I do that for Arrays.

Any tips?

Thank you!

5 REPLIES 5

koryknick
Employee
Employee

My pleasure @ionutbarna - glad you found your solution!