Help with challange

Tell us what’s happening:
Honestly, I can't get through with this challenge, it keeps saying " Once both functions have ran, the sum should be equal to 8" how can I do that? I tried adding both functions together and nothing. I tried creating another variable and adding both function it is still nothing. I don't understand where I went wrong

Your code so far


// Example
var sum = 0;
function addThree() {
sum = sum + 3;
}

// Only change code below this line
function addFive(){
var sum = sum + 5;
}

// Only change code above this line
addThree();
addFive();

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36.

Challenge: Understanding Undefined Value returned from a Function

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/understanding-undefined-value-returned-from-a-function

declaring the variable with var inside the function you are creating a local variable, so you are not changing the global variable

1 Like

That actually made perfect sense when I looked at it again, thank you.

1 Like