Control and looping structure in javascript
1. If Statement
Syntax : If statementif(condition) Show
Example : Simple Program for IF Statement
Output:
2. If – Else Statement
Flow Diagram of If – Else
Statement Syntax : If-Else statementif (condition) Example : Simple Program for If-Else Statement Output:
3. Switch Statement
Flow Diagram of Switch Statement Syntaxswitch(expression) Example : Simple Program for Switch Statement Output:
4. For Loop
It includes three important parts: 1. Loop Initialization 2. Test Condition 3. Iteration Flow Diagram of 'For' Loop Syntaxfor(initialization; test-condition; increment/decrement) Example : Palindrome Program using For Loop Output:
5. For-in Loop
Syntaxfor (variable_name in Object) 6. While Loop
Flow Diagram of While Loop Syntaxwhile (condition) Example : Fibonacci Series Program using While Loop Output: 7. Do-While Loop
Flow Diagram of Do – While Syntaxdo Example : Simple Program on Do-While Loop Output: Difference between While Loop and Do – While Loop
8. Break Statement
Syntax: Flow Diagram of Break Statement 9. Continue Statement
Flow Diagram of Continue Statement Syntax: continue; What are control structures in JavaScript?The control structures within JavaScript allow the program flow to change within a unit of code or function. These statements can determine whether or not given statements are executed - and provide the basis for the repeated execution of a block of code.
What are looping control in JavaScript?Loop control statements are certain JavaScript statements that interrupt the normal flow of the program. They direct the program control to a specific location in the code. Therefore, sometimes, we also call them “Jump Statements”.. continue.. break.. label.. What are looping control structures?Control structures alter the normal sequential flow of a statement execution. Loops allow the a block of statements to be executed repeatedly without actually writing them down numerous times.
What are the 4 control structures?if-else conditionals, case statements, for loops, and while loops are all control structures.
|