CSC 160 - Computer Programming for Non-majors

Assignment #4: Adding a for loop to a program

Due Tuesday, October 26, 2010

Below you will find a payroll that asks the user for the number of times to repeat a message. but it only prints the message once.

Add the necessary for loop so the program will print the message however many times the user specified.

<html>
  <head> <title> Lab Assignment #5</title>
  </head>
  <body>
    <script type = "text/javascript">
      var totalTimes;

      totalTimes = parseInt(prompt("How many times do you want to print the message", 0));
      document.write("<p>I am writing it " + totalTimes + 
                   " times.</p>");
    </script>
  </body>
</html>

[Back to the Lab Assignment List]