Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basic program gives only one quess and then the program ends.

Similar presentations


Presentation on theme: "Basic program gives only one quess and then the program ends."— Presentation transcript:

1 Basic program gives only one quess and then the program ends.

2 guessing until the user guesses the correct answer.

3 until I guess correctly.

4 the box.

5 Random number is determined outside the loop because we don't want it to change.
Guess changes so we want it in the loop. !=

6 saying TheRanNum != myGuess

7 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.

8 is within the outer loop.
controls playing again.

9 The bottom diamond is checking for playAgain != N

10 This program does a document
This program does a document.write on the screen and puts up an alert box.

11

12 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.

13

14

15

16

17

18

19

20

21 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.

22


Download ppt "Basic program gives only one quess and then the program ends."

Similar presentations


Ads by Google