Understanding-undefined-value-returned-from-a-function

Understanding-undefined-value-returned-from-a-function
0.0 0

#1

Tell us what’s happening:

I don’t know why it gives me an error saying that sum should be equal to 8.

Your code so far



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

// Only change code below this line
function addFive(sum){

  sum = sum + 5;

}




// Only change code above this line
var returnedValue = addFive(3);


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


#2

You are initially setting sum to 8, and then the function addFive sets it to 13 (because that’s what 8 + 5 is).


#3

The function addFive should not take any argument.


#4


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

// Only change code below this line

function addFive(){
sum = sum + 5;
}

// Only change code above this line
var returnedValue = addFive();

#6

You are calling the function addFive(3), but not returning anything from the functions.