如何在reduce方法上打破迭代?
对于
for (var i = Things.length - 1; i >= 0; i--) {
if(Things[i] <= 0){
break;
}
};
Run Code Online (Sandbox Code Playgroud)
降低
Things.reduce(function(memo, current){
if(current <= 0){
//break ???
//return; <-- this will return undefined to memo, which is not what I want
}
}, 0)
Run Code Online (Sandbox Code Playgroud)