Please help with function question

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

  **Your code so far**

// Setup
let sum = 0;

function addThree() {
sum = sum + 3;

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

// Only change code above this line


My code above is correct and lets me get to the next lesson, but I don’t get it so I’m hoping for some clarity.

In my function addFive, I don’t understand why it can’t be:
sum + 5;

instead of needing to say:
sum = sum + 5;

Why do I need to change the value of sum to sum + 5, instead of just saying when this function is run, it should add 5 to the sum (sum + 5)??

Hopefully that makes sense.

1 Like

What does this line do with the result of this calculation? Where does it go?

Ahhh OK I understand, thank you!

1 Like

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