Javascript Break Early Reduce () Método
[ 1, 2, 3, 4, 5].reduce((sum, el, _, arr) => {
if (el === 4) {
arr.length = 0;//Array passed to callback is now empty
return sum;
}
return sum + el;
}); // return 1 + 2 + 3 = 6
Stanislav Topikha