Below code demonstrates the usage of array method:
console.log("total = "+0+" ; value = "+Arr1[0]);
function performReduction(total,value) {
console.log("total = "+total+" ; value = "+value);
return total + value;
}
reducedOutput = Arr1.reduce(performReduction);
console.log("total = "+reducedOutput+" ; value = "+"");
console.log(reducedOutput);
Refer: https://docs.microsoft.com/en-us/scripting/javascript/reference/reduce-method-array-javascript
Practice at: http://jsbin.com
- reduce
console.log("total = "+0+" ; value = "+Arr1[0]);
function performReduction(total,value) {
console.log("total = "+total+" ; value = "+value);
return total + value;
}
reducedOutput = Arr1.reduce(performReduction);
console.log("total = "+reducedOutput+" ; value = "+"");
console.log(reducedOutput);
Refer: https://docs.microsoft.com/en-us/scripting/javascript/reference/reduce-method-array-javascript
Practice at: http://jsbin.com
No comments:
Post a Comment