JAVASCRIPT CONTROL FLOW STATEMENTS

 

CONTROL FLOW STATEMENTS 


  1. If Statement
  2. If Else Statement
  3. If Else if statement
  4. For Loop
  5. White loop 
  6. Break and Continue
  7. Time out and intervel 
  8. Exception Handling 
IF STATEMENT

The if statement executes a block of code if the given condition is true.

Syntax:

if (condition) {

}


Example:

If age is more then 18 pop up dialogue box is open .

<html>

<head>

    <title>if statement</title>

</head>

<body>

    <button onclick="ifstatement()">click me</button>


<script>

    function ifstatement( ) {

        const age = 20;

        if (age > 18 ) {

            alert("age is more then 18 years old");

    }

<script>

</body>

</html>


IF-ELSE STATEMENT:

  The else statement executes a Block of codes when the given condition to if is true 

Syntax 

if (condition) {

}else{

}