write the syntax for the following with an example :
1. If
2. If - else
3. If - elif ladder
4. While
5. For
6. Break
7. Continue
Answers
Answer:
let cups = 4;
//If ->
if(cups=4){console.log("We Have 4 Cups")}
// If Else
if(cups=4){console.log("We Have 4 Cups")}
else {console.log("We don't have 4 Cups")}
//If Else ladder
if(cups=4){console.log("We have 4 Cups")}
else if (cups=3){console.log("We have 3 cups")}
else {console.log("We neither have 4 Cups nor 3 cups")}
//while
while(cups=4){console.log("We have 4 Cups");cups++)
//For
for(int i=7, i>=cups, i--){console.log("interger "I" is greater than 7 or equal to 4)
//break
if(cups=4){console.log("We have 4 Cups")}
break;
//continue
if(cups=>1){console.log(//whatever); cups++}
continue;
Explanation:
If loop - If a condition is true it will execute
if Else - First checks the if condition, if it's not true it will execute the else code
if Else ladder - First checks the If condition, then check other conditions, it's basically an if Else loop but can be unlimited and multiple conditions can be checked
While- will execute WHILE a condition is true, insert an increment or a break in this
For- This is mostly like if Else, in this you can declare an integer to check the condition.
Break- is used in loops, it will stop checking conditions once break; is executed
Continue- opposite of break; will continue the loop, it is not used that often
Please Mark me as brainliest.
Signing Off
-Maulik Gamer