Jump to content

nameLength


Guest Dibbets

Recommended Posts

Guest Dibbets

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...