Jump to content


nameLength


  • Please log in to reply
1 reply to this topic

#1 Guest_Dibbets

Guest_Dibbets
  • Guests

Posted 03 September 2011 - 02:24 PM

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>
  • 0

#2 Ben

Ben

    Administrator

  • Administrators
  • 5,640 posts
  • LocationChico, CA

Posted 03 September 2011 - 02:42 PM

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.”);

  • 0
Benjamin Falk
Falken Creative : Twitter




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users