javascript - console.log error showing Uncaught SyntaxError: Invalid or unexpected token - Stack Overflow

I'm trying to get into javascript and just figure out how how to print statements in the console.

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.

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.

Share Improve this question asked Jun 20, 2017 at 19:19 Alex TAlex T 131 silver badge3 bronze badges 1
  • 1 Pay attention to what you copy paste. The quotes surrounding Hello world! is the problem. Manually type it and see – Kaushal Niraula Commented Jun 20, 2017 at 19:23
Add a ment  | 

2 Answers 2

Reset to default 2

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

Change

console.log(“Hello world!”);

to

console.log("Hello world!");

is not valid. Downside to copy/paste :)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745614276a4636135.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信