const arr = [{item:'a', value:false}, {item:'b', value:true}, {item:'c', value:true}, {item:'d', value:false}];
const startIndex = 2;
Given startIndex find next object in array with value=true. Iteration must be forward and, if not found, start from index 0. Should return arr[1];
I've just hit the wall and seems can't find an iteration method:/
let result = {};
for (let i = startIndex + 1; i < arr.length; i++) {
if (!arr[i] && i < arr.length) {
result = arr[i];
}
}
console.log(result);
indexOfit takes 2 parameters... look it upvalueproperty and not breaking if foundstartIndex + 1forward, if not found start the second one from 0 tostartIndex. Why do you want it to be 1 loop?