I need reduce() method working in some condition not satistification the stop the execution.
Please Help me.
const array = ['apple', '-pen', '-pineapple', '-pen'];
const x = array
.slice(0) // create copy of "array" for iterating
.reduce((acc, curr, i, arr) => {
if (i === 1)
arr.splice(1); // eject early by mutating iterated copy
console.log('i=> ', i);
}, '');