Uncaught SyntaxError: expected expression, got '<'

Hello, I’ve finished the JS beginners course from CodeCademy, and I thought I’d have a go at trying to follow a simple YouTube game tutorial. I’m using Visual Studio Code, and coding in HMTL and JavaScript.

I’ve barely done anything, but when I wrote something in the JavaScript file, and opened the Developer Tool in the web, it gave the following error from the Console::
Uncaught SyntaxError: expected expression, got ‘<’

I’ve used HTML for a website before and never had a problem, so I’m assuming it’s to do with the JavaScript side of it. This is my first time making anything proper with JS so I’d really appreciate a broken down explination of this. Here’s a screenshot of my HTML code in case it’ll help…

P.S. everything above the body has been created by typing “!” and then TAB so I doubt there’s any errors as I didn’t touch it. All I wrote was everything in the body
Thank you so much in advance! :blush:


So do I. Therefore we need to see your Javascript code. Please post the code (properly formatted) rather than a screenshot.

It’s only one line just to test if it was working…


Really not sure what’s the problem with it lol

Yes, that’s fine, indeed.
I found a spelling error in your html file: You wrote scr instead of src. That needs to be:

script src="index.js"

I would also recommend deleting the spaces around the equal signs in your html.

1 Like

Thank you!! I can’t believe I didn’t see that :sweat_smile:
I changed it and re-opened the live web server and it’s all working now. I appreciate it, thank you :slight_smile:

1 Like