Understanding Undefined Value returned from a Function

Tell us what’s happening:
None of the red, circled white x’s are being checked off even though I am confident I have met the task’s requirements. Is the website currently glitched? Should I clear cookies or wait for an update? Is this user error?

Your code so far


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

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


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


Your browser information:

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

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

You’re not returning anything, you’re just assigning variables. You need to return a value from a function, otherwise it won’t return anything except undefined.

The assignment’s task ask me to omit a return value so that the function returns undefined. Am I wrong?

P.S. I just tried returning undefined to no avail.

This worked for me.

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

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

}

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

1 Like

This still does not mark any tasks as complete and the output simply says, “running tests.” Is the problem my web browser (MS Edge)?

I ran the test with the following code and passed. I would try to run this code on Chrome or Firefox to see what you get.

// 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();

Thank you… I will try that soon and update the thread.

Apologies for my unhelpful reply, I didn’t read the challenge description properly.

So what works then cause i do not understand

Just exactly what was in the original post, I assume OP have a browser issue. The challenge is just having you write a function that doesn’t return anything.