Jump to content


Photo

Stuck On First Example


  • Please log in to reply
2 replies to this topic

#1 Andy75

Andy75

    New Member

  • Members
  • Pip
  • 1 posts

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>

#2 lemuel

lemuel

    Super Veteran Member

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 577 posts

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.

Edited by lemuel, 05 August 2014 - 09:01 AM.


#3 Danny013

Danny013

    New Member

  • Members
  • Pip
  • 2 posts

Posted 28 December 2014 - 05:36 PM

Had a similar problem. TextEdit adds in extra information not readable by browsers. Look at the source code in the browser and you will see how much embedded information text edit places in files. Check out http://support.apple.com/kb/TA20406 to fix.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users