JSFiddle - React, Tailwind, and code Playground
JavaScript
function findEvenIndex(arr)
{
var r = 0;
var s = 0;
arr.forEach(function(i)
{
r = i;
while (r > 0){
r--;
s += arr[r];
console.log(s);
}
if (s == 3)
{
r = 3;
return r;
}
s = 0;
});
return r;
}
console.log(findEvenIndex([1,2,3,4,3,2,1]),3, "The array was: [1,2,3,4,3,2,1] \n");