THE END


You should be able to pick out the magic here. You're setting up a prompt and assigning it a variable name. We called it "tellme". Next you change that variable to represent the "loops" number using the eval() function. It's pretty much the same from then on out. Here's the full script:

<html>
<head>
</head>
<body bgcolor="white">
<SCRIPT type="text/javascript">
  tellme=prompt
  ("How many Happy's do you want before the word Birthday?")
  loops=eval(tellme)
  num=1
  while (num <= loops)
     {
     document.write("Happy ")
     num=num+1
     }
     document.write("Birthday")
</script>
<p>
THE END
</body>
</html>

Close this window to return to Primer #25