Skip to content

Instantly share code, notes, and snippets.

@MariaSzubski
Last active July 21, 2016 21:47
Show Gist options
  • Select an option

  • Save MariaSzubski/65d131ff1817548b4bf35567c5ecac2c to your computer and use it in GitHub Desktop.

Select an option

Save MariaSzubski/65d131ff1817548b4bf35567c5ecac2c to your computer and use it in GitHub Desktop.
Sum of values in an array. #hackerrank #warmup
/*
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