I have a nested array that changes dynamically. I need to check if the array contains an object and then modify the object keeping the rest of the items the same.
Sample:
var input = [
['a', 'b'],
['c', 'd'],
['e', ['f', 'g']],
['h', ['i', 'j']]
]
In this nested array, I would like to find f and change it to f-is-found
var result = [
['a', 'b'],
['c', 'd'],
['e', ['f-is-found', 'g']],
['h', ['i', 'j']]
]
The problem is that f can change it's location in the array, so I can't use any hard coded ways of accessing the array.
Help is appreciated, thank you