Created
August 30, 2019 01:57
-
-
Save dottedsquirrel/2dcf5b8c8eb68d7d064fd07bf2237616 to your computer and use it in GitHub Desktop.
JavaScript array 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
let numbers = [100, 20, 10]; | |
// result will return 70 as the value | |
// The function inside reduce will run twice. | |
// the first time, x = 100, y = 20 | |
// the second time, x = 80, y = 10 | |
result = numbers.reduce((x, y) => { return x - y; }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment