Hey Student,
Oh dear, this is a tricky one. It's definitely messed me up in the past. What's happening here is an issue of scoping and closures. A few things to point you in the right direction:
- Study block scoping versus function scoping in JavaScript
- Study JavaScript's variable declarators,
var
,let
, andconst
, and understand the differences between their uses - Study up a bit on closures in JavaScript
- With your new knowledge, try to make
btnNum
block scoped instead of function scoped