O'Reilly Forums: Stuck On First Example - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Stuck On First Example

#1 User is offline   Andy75 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 05-August 14

Posted 05 August 2014 - 02:29 AM

I'm stuck on the first example on writing javascript in the body tag. I'm using mac and text editor for my code. First i hade some problem with quotation marks but i found a way to avoid that. But, when i open my index.html in Chrome (mac) and go to console i get: Uncaught SyntaxError: Unexpected token ILLEGAL, index.html:10

Here's my code:

<!doctype html>

<html>
<head>
<meta charset="utf-8">
<title>Javascript</title>
</head>
<body>
<script>
var word = ”bottles”;
var count = 99;
while (count > 0){
console.log(count + ” ” + word + ” of beer on the wall”);
console.log(count + ” ” + word + ” of beer,”);
console.log(”Take one down, pass it around,”);

count = count - 1;

if(count > 0){
console.log(count + ” ” + word + ” of beer on the wall.”);
}
else{
console.log(”No more ” + word + ” of beer on the wall.”);
}
}
</script>
</body>
</html>
0

#2 User is offline   lemuel 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 577
  • Joined: 13-April 09

Posted 05 August 2014 - 09:00 AM

I don't know what text editors are available on Macs, but the one you are using is inserting "fancy" quotes and the JavaScript parser doesn't know what to do with them. The quotes in this line
<meta charset="utf-8">

are correct, all the others are not. You need to Save As 'txt', perhaps, or use an editor that doesn't try to help you so much.

This post has been edited by lemuel: 05 August 2014 - 09:01 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users