05/06/2026
Fixing a finalScore Bug with the Prefix Increment Operator FreeCodeCamp
Join Our FREE Skool Coding Community: https://vist.ly/53abb
This is a video about Debug Increment and Decrement Operator Errors in a Buggy App, User Story 2
We are going over how to satisfy a user story requiring a variable named finalScore to evaluate to 8 while still using the increment operator. The presenter inspects the code and console output, noting that a prefix increment (++score) is currently used when assigning finalScore, which increases score and makes finalScore 9. To keep finalScore at 8, they change the expression to use the increment after the assignment (postfix), so finalScore captures the original value before score is incremented. They also demonstrate that score later becomes 9 after the increment, emphasizing that prefix vs postfix placement affects both stored values and when the variable is updated.