CONTROL STATEMENTS: =================== sequential execution program: line-1 line-2 line-3 Why? ==== 1) to make execute the specific block of the code/program 2) to make execute the block of code repeatedly for certain number of times. 3) to jump from one block of code to another block. => three types: 1) Conditional Statements 2) Looping Statements 3) Transfer Statements Conditional Statements ====================== ==> also called as "selection statement". simple if if else statement nested if else if else if else ladder simple if ========= Syntax: if(condition) { if block } Statements; // WAP TO CONVERT THE NUMBER TO POSITIVE IF IT IS ENTERED AS NEGATIVE. let n = -12; if(n < 0) { // converting into positive n = -n; console.log("The Value after the sign change = "+n); } console.log("The Number = "+n); ==================================== if-else: ======== Syntax: if(condition) { if block } else { else block } // WAP TO CHECK WHETHER WE CAN ABLE TO MAKE THE SQUARE WITH THE GIVEN FOUR INTEGER VALUES OR NOT. var s1 = 10; var s2 = 11; var s3 = 10; var s4 = 12; if(s1 == s2 && s1 == s3 && s1 == s4) { console.log("It is a Square."); } else{ console.log("It is not a Square."); } ======================================== // WAP TO CHECK THE YEAR IS LEAP YEAR OR NOT. year = 1999; // year % 4 == 0 // year % 100 != 0 // year % 400 == 0 if((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) { console.log("This is a leap year."); } else { console.log("This is not leap year."); } =========================================== // WAP TO FIND THE DIFFERENCE OF TWO NUMBERS IF FIRST NUMBER IS GREATER THAN THE SECOND OTHERWISE FIND ITS SUM. /* n1 > n2 ==> n1 - n2 n1 < n2 ==> n1 + n2 */ n1 = 12; n2 = 10; var result = 0; if(n1 > n2) { result = n1 - n2; } else { result = n1 + n2; } console.log("The Result = "+result); ==========================