Last active
July 21, 2016 21:47
-
-
Save MariaSzubski/65d131ff1817548b4bf35567c5ecac2c to your computer and use it in GitHub Desktop.
Sum of values in an array. #hackerrank #warmup
This file contains hidden or 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
| /* | |
| Solution for HackerRank > Algorithms > Warmup > A Very Big Sum | |
| https://www.hackerrank.com/challenges/a-very-big-sum | |
| */ | |
| function main() { | |
| var n = 5 | |
| var arr = [1000000001,1000000002,1000000003,1000000004,1000000005]; | |
| // Add all values in the array | |
| var sum = arr.reduce((total, current) => total + current, 0); | |
| console.log(sum); | |
| } | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment