When your code fails, you'll see an error in the console. An error message has parts: the error type, the message, and the location.
ReferenceError: userName is not defined
at script.js:5:13
This tells you: it's a ReferenceError, the variable userName doesn't exist, and the problem is on line , column of script.js. Read the full message before trying fixes.