Guest Dibbets Posted September 3, 2011 Report Share Posted September 3, 2011 Hi guys, My code isnt't working. This property is supposed to return the length of the string in characters. What's wrong? <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> <html lang=”EN” dir=”ltr” xmlns=”http://www.w3.org/1999/ xhtml”> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>HelloWorld.html</title> <script type = “text/javascript”> //<![CDATA[ //from nameLength.html var person = prompt(“Please enter your name.”); var length = person.length; alert(“Hi, “ + person + “!”); alert(“The name “ + person + “ is “ + length + “ characters long.”); //]]> </script> </head> <body> Dit is een test. </body> </html> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted September 3, 2011 Report Share Posted September 3, 2011 Did you copy this from an online blog or something similar? Blogs like Wordpress change the straight double quote (") to a typographically correct slanted quote. This means you need to go through and replace any double quotes with the standard double quote from the keyboard. Also, you can't separate your alert() into two lines, so this needs to be put on one line: alert(“The name “ + person + “ is “ + length + “ characters long.”); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.