| 1. |
JavaScript If-Else Statements |
|
Answer» The if-else statements are simple to comprehend. You can use them to set conditions for when your code runs. If specific requirements are met, something is done; if they are not met, another action is taken. The switch statement is a concept that is comparable to if-else. The switch however allows you to choose which of several code blocks to run. The syntax of if-else statements in JavaScript is given below: if (check condition) {// block of code to be executed if the given condition is satisfied } else { // block of code to be executed if the given condition is not satisfied } Loops in JavaScript: Most programming languages include loops. They let you run code blocks as many times as you like with different values. Loops can be created in a variety of ways in JavaScript:
// code to be executed in loop }
while(condition checking for the loop){ // 1. code to be executed in loop // 2. updation of the loop variable }
do{ // 1. code to be executed in loop // 2. updation of the loop variable }while(condition checking for the loop); There are two statements that are important in the context of loops:
|
|