Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="description" content="Lab test 2 for COMP1231">
- <meta name="keywords" content="Lab test 2, COMP1231, Loops">
- <meta name="author" content="Brendan Bernas brendan.bernas@georgebrown.ca">
- <title>Lab Test 2</title>
- </head>
- <body>
- <h1>Lab Test 2</h1>
- <div id="divWrite"></div>
- <script>
- var userMin = prompt("Please enter the first number");
- var userMax = prompt("Please enter the second number");
- var outputString = ""
- if (isNaN(userMin) || isNaN(userMax)) //checks if either input is not a number
- {
- outputString = "Please enter two numbers";
- }
- else if (userMin >= userMax)
- {
- outputString = "Please make sure the second number is greater than the first number";
- }
- else
- {
- var i = 1; //reset counter
- var count = userMin;
- while (count < userMax) //repeats block until it reaches the max number
- {
- i = 1;
- while (i <= count)
- {
- outputString += "*";
- i++;
- }
- outputString += "<br>";
- count++;
- }
- while (count >= userMin) //repeats block from max number to min number
- {
- i = 1;
- while (i <= count)
- {
- outputString += "*";
- i++;
- }
- outputString += "<br>";
- count--;
- }
- }
- document.getElementById("divWrite").innerHTML = outputString;
- </script>
- <hr>
- <script src=http://my.gblearn.com/js/loadscript.js></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement