Functional Programming - Avoid Mutations and Side Effects Using Functional Programming

Tell us what’s happening:
Describe your issue in detail here.
Just wondering why the increment operator (++) did not change the fixedValue variable from 4 to 5? According to the hints it should but when I console.log it it still shows 4?

Your code so far

// The global variable
let fixedValue = 4;

function incrementer() {
  // Only change code below this line
return fixedValue ++;

  // Only change code above this line
}
let result = incrementer();
console.log(result);




Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15

Challenge: Functional Programming - Avoid Mutations and Side Effects Using Functional Programming

Link to the challenge:

In did change the value. But the old value was returned first. Prefix vs postfix has different behavior

Oh I see, thanks now I understand.

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