\n\n\n\n\n\n The return Statement
\nslide5. 5 In JavaScript we have the following conditional statements:\n\nif statement - use this statement to execute some code only if a specified condition is true\n\nif...else statement - use this statement to execute some code if the condition is true and another code if the condition is false\n\nif...else if....else statement - use this statement to select one of many blocks of code to be executed\n\nswitch statement - use this statement to select one of many blocks of code to be executed\n\nNote that if is written in lowercase letters. Using uppercase letters (IF) will generate a JavaScript error! Conditional Statements
\nslide6. 1. if Statement\nSyntax if (condition)\n{\ncode to be executed if condition is true\n}\n\nExample:\n\nHello World\n\n\n 6
\nslide7. 7 2. If else Statement •Use the if....else statement to execute some code if a condition is true and another code if the condition is not true.\n\nSyntax\nif (condition)\n{\ncode to be executed if condition is true\n}\nelse\n{\ncode to be executed if condition is not true\n}
\nslide8. 8 If..else Statement–Example
\nslide9. 9 3. If…else if…else Statement •Use the if....else if...else statement to select one of several blocks of code to be executed. Syntax\nif (condition1)\n{\ncode to be executed if condition1 is true\n}\nelse if (condition2)\n{\ncode to be executed if condition1 is false and condition2 is true\n}\nelse\n{\ncode to be executed if neither condition1 nor condition2 is true\n}
\nslide10. 10 If…else if…else Statement– Example
\nslide11. 11 4. Switch Statement Use the switch statement to select one of many blocks of code to be executed.\n\nSyntax\nswitch(n)\n{\ncase 1:\nexecute code block 1 break;\ncase 2:\nexecute code block 2 break;\ndefault:\ncode to be executed if n is different from case 1 and 2\n}
\nslide12. 12 Switch Statement–Example
\nslide13. 13 Loops execute a block of code a specified number of times, or while a specified condition is true.\n\nThe for loop has the following syntax:\n\n\nfor (statement 1; statement 2; statement 3) { code block to be executed\n} For loop
\nslide14. 14 Loop through the six different HTML Headings.\n\n\n\n\n\n\n\n For Loop–Example
\nslide15. 15 While Loop Syntax\nwhile (condition)\n{\ncode to be executed\n}\nExample:\n\n\n

Introduction to Web Programming Lecture 9:

Introduction to Web Programming Lecture 9:
1 / 1
Introduction to Web Programming Lecture 9: - slide 1 of 28 Introduction to Web Programming Lecture 9: - slide 2 of 28 Introduction to Web Programming Lecture 9: - slide 3 of 28 Introduction to Web Programming Lecture 9: - slide 4 of 28 Introduction to Web Programming Lecture 9: - slide 5 of 28 Introduction to Web Programming Lecture 9: - slide 6 of 28 Introduction to Web Programming Lecture 9: - slide 7 of 28 Introduction to Web Programming Lecture 9: - slide 8 of 28 Introduction to Web Programming Lecture 9: - slide 9 of 28 Introduction to Web Programming Lecture 9: - slide 10 of 28 Introduction to Web Programming Lecture 9: - slide 11 of 28 Introduction to Web Programming Lecture 9: - slide 12 of 28 Introduction to Web Programming Lecture 9: - slide 13 of 28 Introduction to Web Programming Lecture 9: - slide 14 of 28 Introduction to Web Programming Lecture 9: - slide 15 of 28 Introduction to Web Programming Lecture 9: - slide 16 of 28 Introduction to Web Programming Lecture 9: - slide 17 of 28 Introduction to Web Programming Lecture 9: - slide 18 of 28 Introduction to Web Programming Lecture 9: - slide 19 of 28 Introduction to Web Programming Lecture 9: - slide 20 of 28 Introduction to Web Programming Lecture 9: - slide 21 of 28 Introduction to Web Programming Lecture 9: - slide 22 of 28 Introduction to Web Programming Lecture 9: - slide 23 of 28 Introduction to Web Programming Lecture 9: - slide 24 of 28 Introduction to Web Programming Lecture 9: - slide 25 of 28 Introduction to Web Programming Lecture 9: - slide 26 of 28 Introduction to Web Programming Lecture 9: - slide 27 of 28 Introduction to Web Programming Lecture 9: - slide 28 of 28
Introduction to Web Programming Lecture 9: Introduction to JavaScript (Part 2) 1 Natheer Gharaibeh 2 Outlines of todays lecture Functions Conditional statements Loops Popup windows Events 3 A JavaScript function is a block of

Related Topics

Download this presentation From Below

"Introduction to Web Programming Lecture 9:" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
Introduction to Web Programming Lecture 9: Introduction to JavaScript (Part 2) 1 Natheer Gharaibeh<br>
02
2 Outlines of today’s lecture • Functions • Conditional statements • Loops • Popup windows • Events<br>
03
3 • A JavaScript function is a block of code designed to perform a particular task.
A function will be executed by an event or by a call to the function.
JavaScript Function Syntax
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().
Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).
The parentheses may include parameter names separated by commas: (parameter1, parameter2, …)
The code to be executed, by the function, is placed inside curly brackets: {} functionName(parameter1, parameter2, parameter3)
{
code to be executed
} JavaScript Functions<br>