Virtually the same as solution but not working

So I wrote:

// The global variable
var fixedValue = 4;

function incrementer () {
  // Only change code below this line
  return fixedValue++;
  // Only change code above this line
}
var newValue = incrementer(); 
console.log(fixedValue); 

The entire purpose of this challenge is to avoid side effects. The ++ operator changes the value stored in the variable, which is a side effect.

To see this, try calling the function twice. You should get the same number out each time, but your code won’t do that - it will provide two different values.

So I am to understand that

fixedValue++

and

fixedValue + 1

cause two different things?

Yes. The first changes the value stored in the variable. The second does not.

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