Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Qusai Abuein1 Internet & WWW How to program Chap.(7) JavaScript: Control Statements I.

Similar presentations


Presentation on theme: "Dr. Qusai Abuein1 Internet & WWW How to program Chap.(7) JavaScript: Control Statements I."— Presentation transcript:

1 Dr. Qusai Abuein1 Internet & WWW How to program Chap.(7) JavaScript: Control Statements I

2 Dr. Qusai Abuein2 (7.1) Introduction This chapter introduces a general theoretical understanding of the structured programming. The if statement as a control one in the program in introduced. Some reserved words (Keywords) used in the JavaScript. Fig. 7.2.

3 Dr. Qusai Abuein3 (7.2, 7.3, 7.4) Self Study Algorithms Pseudocode Control Structure

4 Dr. Qusai Abuein4 (7.5) The IF statement Same as in the programming language you know (c++).

5 Dr. Qusai Abuein5 (7.6) If … else statement Same as in the programming language you know (c++). The Nested if is also the same as you expect. The conditional operator (?:) is also supported. –document.writeln(grade >= 60 ? ”pass” : “faile”) Nested if … else statement is also supported.

6 Dr. Qusai Abuein6 (7.7, 7.8) While repetition Statement Example in Fig. 7.7 uses the while repetition statement using a counter (fixed value such as 10, or a number “n” read previously by the user) to control the loop (also syntax and concept as you expect). Un initialized variables used in calculations result in logic errors and produce the value NaN. See lines 19 and 20 in Fig.7.7. The calculation is used in line 33.

7 Dr. Qusai Abuein7 (7.9) Repetition Example The example in Fig.7.9 uses a special value called a sentinel value (also called a signal value, a dummy value or a flag value such as “-1”) to stop or control the while loop.

8 Dr. Qusai Abuein8 (7.10) Repetition Example The example in Fig.7.11 introduces counters in the program: –One to count number of students –Other to count passes results –And other to count filed results Any logical errors in the program ?

9 Dr. Qusai Abuein9 (7.11) Assignment Operators JavaScript provides several compound assignment operators. –C += 3; –C -= 3; –C *= 3; –C /= 3; –C %= 3; See Fig. 7.11

10 Dr. Qusai Abuein10 (7.12) Increment and decrement The increment operator ++ is provided by JavaScript. Also the decrement one --. Fig.7.14 shows the difference between pre-increment and post-increment. See Fig. 7.15 for precedence of operators.

11 Dr. Qusai Abuein11 Endof Chap. (7) Thank you.


Download ppt "Dr. Qusai Abuein1 Internet & WWW How to program Chap.(7) JavaScript: Control Statements I."

Similar presentations


Ads by Google