Skip to main content
JavaScript Bug Hunt Easy +10 XP

Const Reassignment

This code throws an error.

JavaScriptFind the bug
1const count = 0;
2count = count + 1;
3console.log(count);
The bug is on line 2

Select the correct fix

Show answer and explanation

Answer: Use let instead of const

const variables cannot be reassigned. Use let for variables that need to change.

Hint: const means the binding can't change.

What this challenge tests

Bug Hunt in JavaScript: const, let, variables.

Related challenges