Created
June 19, 2022 23:05
-
-
Save geraldotech/cd34c5eb27f7cb50bebf75b181a6d254 to your computer and use it in GitHub Desktop.
reduce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const n = [2,4,6,1,7]; | |
x = n.reduce(function (total,el,ind,arr) { | |
console.log(`index: ${ind}`) | |
console.log(`total: ${total}`) | |
console.log(`el: ${el}`) | |
console.log(`Arr: ${arr}`) | |
return total+= el; | |
},0); | |
console.log(x) //20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment