if that was exactly what the author of the book told you to do, get your money back. In all likelihood there is worse to come.
If you’re curious, the problem was that the document.getElementById statement was being executed before the page was loaded. You can write javascript within the ‘head’ tags, but if it is meant to interact with something on that page, that something has to exist. So, the rule of thumb is: if the code isn’t a function, it doesn’t belong in the head.