How does it know its 8 and sum = 0 ; sum +=5:?

Tell us what’s happening:
how doe it get 8 when
var sum = 0;
sum += 5;

Your code so far

// Setup
var sum = 0;

function addThree() {
sum = sum + 3;

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


// Only change code above this line


Your browser information:

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

Challenge: Understanding Undefined Value returned from a Function

Link to the challenge:

Because you have called addThree() before addFive()

Remember, the sum value at the very top is changed each time you call it.

Try calling another addThree() below the two existing addThree() and addFive() function calls. Sum will be 11.

sum += 5 is same as sum = sum + 5

okey but why do i need to have
addThree() before addFive()
can i just make it var sum = 3 and then sum +=5 and its joining to be 8 that’s the part that is confusing me

Of course, you can do exactly that, however you need to follow what the challenge instructions said or you won’t pass the challenge. I know, it’s very picky.

its good to know that i can do just that cus i was thinking im doing something wrong or idk thanks anyway