Quote:
Originally Posted by HungryChapstick
Say the user guessed correctly in their 1st or 2nd attempt, how would you get it to write, for example, "You guessed correctly on your 2nd attempt?"
|
Code:
if (guess == theNumber) {
var arr = ["", "first", "second", "third", "fourth"]; // note that the zeroth element of the array is blank.
message = "Well done! The number " + theNumber + " was correct! This was your " + arr[i] + " attempt.";
i = tries;
}
I think you should solve the second question yourself, as you will only learn by doing things for yourself, rather than getting others to do your homework for you, but a hint is
message += whatever which appends the new value to the existing value.