Are All of the Tests Correct for Basic JavaScript: Understanding Undefined Value returned from a Function

Are All of the Tests Correct for Basic JavaScript: Understanding Undefined Value returned from a Function
0

#1

One of the tests says that “sum” should equal 8.

However, when I’ve called console.log(sum) I’ve gotten 5, even though all of the tests pass. It makes sense that I’ve gotten 5, since sum only gets called by one use of addFive(). This suggests to me that the test is not correct, or the description of the test is not correct on the page.


#2

Can you please provide your code and a link to the challenge?


#3

Yes, I can.

Proof:

The challenge link.

My code, though I’ve added a console.log(sum) before all of the other code:

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

// Only change code below this line

function addFive() {
  sum += 5
}
console.log(sum);
// Only change code above this line
var returnedValue = addFive();
console.log(sum);

Maybe the test is alright, but the instructions need something about calling addThree also.