Basic program gives only one quess and then the program ends.
guessing until the user guesses the correct answer.
until I guess correctly.
the box.
Random number is determined outside the loop because we don't want it to change. Guess changes so we want it in the loop. !=
saying TheRanNum != myGuess
Now I want to change the program so I allow the user to play multiple times. I will use a prompt where they can choose to play again.
is within the outer loop. controls playing again.
The bottom diamond is checking for playAgain != N
This program does a document This program does a document.write on the screen and puts up an alert box.
window.prompt(...) each variable an initial value. The user is then prompted to enter a number, the number is assigned to the defined variable. Then I do a calculation and store it in the variable ans. Finally I document.write the contents of the variable ans.
together as one. I entered 3 and 4 so concatenated they are 34. parseFloat and parseInt are two ways to convert to a number. You have to do this when using the + because the plus has two meanings. It can mean add or it can mean concatenate. It is context driven so if we convert to numbers, it will assume the + means add. Note when I used the + without converting, the program concatenated and put the concatenated numbers in ans.