I am trying to solve "A very big sum" challenge on Hacker Rank: https://www.hackerrank.com/challenges/a-very-big-sum/problem
In there I have to sum all the numbers in the array given so I came up with two solutions:
First solution
function aVeryBigSum(ar){
let sum = 0;
for(let i = 0; i < ar.length; i++){
sum += i;
}
}
Second Solution
function(ar){
let sum = ar.reduce((accumulator, currentValue) => {
accumulator + currentValue;
});
}
But none of them work and I don´t know why, I am thiniking maybe I am not writing it as Hacker Rank wants me to but I am not sure