...

View Full Version : How to ask the question again?



henry_smith56
10-19-2006, 05:10 AM
I'm having trouble having it to re-ask the window.promt after I give the window alert:
Here is the code:
<html>
<head>
<title> Guess My Number! </title>
</head>


<body>

<script language = "JavaScript">

// hw 7 - let the computer generate a number and the user guess the number

var x, guess;

x = Math.round(Math.random()*(100)+1);

guess = parseInt(prompt( "I have a number between 1 to 100. Please guess it:"));

while (guess<=99)
{

if (guess>x)
window.alert("Your number is too high. Try another one.");
else if (guess<x)
window.alert("Your number is too low. Try another one.");
else if (guess=x)
window.alert("You got it! CONGRATULATIONS!!!!!");
}


</script>
</body>
</html>

What do I need to change for it to ask the : guess = parseInt(prompt( "I have a number between 1 to 100. Please guess it:")); again?

_Aerospace_Eng_
10-19-2006, 05:16 AM
Is this an assignment?

henry_smith56
10-19-2006, 05:24 AM
yes this is an assignment, i just need help on having to ask the prompt again

felgall
10-19-2006, 07:56 AM
copy the statement that displays the prompt into the loop after the too high/low messages.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum