Hi @hollydavis541,
Hope you are well; thanks for posting to our discourse forum. You have uncovered a minor error in our code. The line is wrong, and should be
var btn = document.querySelector(‘button’);
This is the first time btn
appears in the code — where we first initialise and declare it. So really we should give it the proper initialization keyword (var
, or in more modern JS you might use const
, as the value of btn
never changes in the code.)
In many cases, not including the keyword won’t cause any problems, but it is a good practice to always include it as it can cause unexpected behaviour. For example the variable will automatically become part of the global scope, no matter where you initialise it…