Well, it's a pretty common beginners mistake. And it's not line 5 (although there is one), the code execution stops at line 3, where the first error is encountered, Mylisa_beth. Everything is linked properly Xyenia 🦉. In fact everything is done by the playground. You can't really see it but all the "links" are located in the head section. This is the most common and preferred way.
You need to delay the script execution until the page is fully loaded. Using defer attribute in the script tag could help. But you can't edit that one, so the Coder's solution the best here.
Thank you for the answer Xyenia 🦉 but alas that didn't help me. It makes no sense because I just made an examle code. I don't want anything special. I want to read contents of the elements BEFORE any manipulation or assignment which wouldn't work anyway after an error :(
You haven't manipulated the innerHTML, just declared variables with no modification or assigned value to what the document element should be.
Check here for an idea