Hello!
So, here is my problem.
I have to write a number-guessing game that prompts the visitor to guess the right number in a maximum of 4 attempts. If the visitor guesses the target number within 4 tries, I want to write an alert that congratulates them as well as indicates the number of tries taken.
If they guess incorrectly, I want to prompt with "Try again."
And I finally want to keep track of each number they typed with a document.write.
I have something like this, but its just not working out:
Code:
<script type="text/javascript">
var count = "" ;
if (count >=0 && count <=88) {
for (i=1; i<=4; i++) {
count = prompt("I'm thinking of a number between 0-88. Can you guess it?", "");
document.write("Guess #" + i + ":" + count + "<br />");
}}
else if (count>88){
alert("Too high!")
}
else if (count=55){
alert("Congratulations, you guessed it in " + i + " tries!)
}
else{
alert ("Guess again!")
}
</script>
Thank you for your time.