Https://beta.freecodecamp.org/en/challenges/basic-javascript/understanding-undefined-value-returned-from-a-function

Https://beta.freecodecamp.org/en/challenges/basic-javascript/understanding-undefined-value-returned-from-a-function
0.0 0

#1

Tell us what’s happening:
It’s an exercise.
requirements:
addFive should be a function
addFive should be a function
sum should be equal to 8
Returned value from addFive should be undefined
Inside of your functions, add 5 to the sum variable

Returned value from addFive should be undefined
Inside of your functions, add 5 to the sum variable

I don’t know what’s wrong with my code because it gives me an error on ‘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

In your code on first line sum is already 8 which is not as in example. I think sum should set equal to 0 on first line

this is what should happen
sum is 0
first example function adds 3 so then sum is 3
your function adds 5 so then sum is 8

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

// Only change code below this line

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