Javascript – why return statement doesn't stop the function execution
const arr = [5,1,3,2,6]; const output = arr.reduce(function (acc, curr){ acc = acc + curr; return acc; }, 0); console.log(output); since there is return statement there, why the reduce function keeps iterating as return statement ends any loop or function…