CSC 160 - Computer Programming for Non-majors

Assignment #5: Adding a while loop to a program

Due Tuesday, November 16, 2010

Below you will find a program that needs a conditional loop before it can that let you tell a "Knock, knock" joke.

Enter and run the program. You will need to add a while loop that makes sure that the reply is Orange. Inside the loop you need to repeat the alert and prompt statementis.

<html>
  <body>
    <script type="text/javascript">
      const knock = "Knock, Knock!"
      var reply;

      alert(knock);
      reply = prompt("Who's there?", "");

      //the while loop goes here
      

      alert("Orange you glad I didn\'t say \"banana\" again?");
      
    </script>
  </body>
</html>

[Back to the Lab Assignment List]