1 / 11

Internet & WWW How to program

Learn about control statements in JavaScript, including the if statement, nested if-else statement, while repetition statement, and assignment operators.

greenpaula
Download Presentation

Internet & WWW How to program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Internet & WWWHow to program Chap.(7) JavaScript: Control Statements I Dr. Qusai Abuein

  2. (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. Dr. Qusai Abuein

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

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

  5. (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. Dr. Qusai Abuein

  6. (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. Dr. Qusai Abuein

  7. (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. Dr. Qusai Abuein

  8. (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 ? Dr. Qusai Abuein

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

  10. (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. Dr. Qusai Abuein

  11. End of Chap. (7) Thank you . Dr. Qusai Abuein

More Related