Alex T
Alex T

Reputation: 13

console.log error showing Uncaught SyntaxError: Invalid or unexpected token

I'm trying to get into javascript and just figure out how how to print statements in the console. I keep getting this error in the google chrome console.

Uncaught SyntaxError: Invalid or unexpected token

my code is

<html>

<script>
    console.log(“Hello world!”);
</script>

</html>

I'm sure its something really simple that I'm missing. I wrote the code on the textedit app on mac and then converted it to an html file.

Upvotes: 1

Views: 6116

Answers (2)

Sebastian Nilsson
Sebastian Nilsson

Reputation: 106

You're using “ and ”, which are not valid quotes in the Javascript language. You should use ' or " instead.

Upvotes: 2

jdmdevdotnet
jdmdevdotnet

Reputation: 1

Change

console.log(“Hello world!”);

to

console.log("Hello world!");

is not valid. Downside to copy/paste :)

Upvotes: 2

Related Questions