Could someone please help me solve this?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

// Setup
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

addThree();
addFive();
  **Your browser information:**

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

Challenge: Understanding Undefined Value returned from a Function

Link to the challenge:

Create a function addFive without any arguments.

You missed this instruction. You are modifying your input rather than the global variable.

so then how could i correct the mistake?
ps: thank you for the input

The instructions say to create addFive without any arguments, so I’d remove the argument you have for your addFive function.

if I do that that makes the last task incomplete? I’m a bit confused.

//                ↓ THIS ARGUMENT SHOULDN"T BE HERE
function addFive(sum) {
//                ↑ THIS ARGUMENT SHOULDN"T BE HERE
1 Like

oooh I see that makes a lot of sense. So the solution was to just not put an argument there and have the equation below as sum += 5
thanks a lot

1 Like

Yep. I’m not wild about this challenge because generally you should never modify global variables without good reason but :man_shrugging:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.