In my Javascript/Typescript collection, I have the following items:
[
{"order":1,"step":"abc:","status":true},
{"order":2,"step":"xyz","status":true},
{"order":3,"step":"dec","status":false},
{"order":4,"step":"pqr","status":false},
{"order":5,"step":"tuv","status":false}
....
];
I am looking to create a function that, when called, will locate the first false occurrence (Order:3 in the example above) and change it to true. When the function is called again, it should move on to update the next false element (order:4). The false steps always come after the true ones in the collection.
What is the most efficient and elegant way to write this function with minimal code? I am currently considering looping through all items in the collection manually and updating the first false occurrence found.