Tell us what’s happening:
Hi,
My code is exactly the same as the official answer from FCC but with a different syntax and yet FCC keeps telling me my code is wrong…WHy do I get an output of 6 and not 10 as intended? Whats wrond please?
Your code so far
function sumAll(arr) {
var MaxNumber= Math.max(arr[0],arr[1]);
var MinNumber = Math.min(arr[0],arr[1]);
var temp=0;
for(var i=MinNumber; i<MaxNumber;i++)
{
temp+=i;
}
return (temp);
}
sumAll([1, 4]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/sum-all-numbers-in-a-range