Loop variable with conditional statement in javascript

technical talkiess
0

 Javascript variable and conditional statement:- 


<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>variable and scope in javascript</title>

</head>

<script>

    var a = "test";

    a= "test2";

    // var ki value ko aap chage kar sakte hai

    // iska use jaab hota hai taab jaab uske reuse kar sakte hai .... variable ki value change kar sakte hai

    let b = " test let";

    // let b= "test let change ";

    // console.log(b);


    // constant ki value ko aap na to declare kar sakte ho aur na to reassign kar sakte ho  

    // iska use apko agar lagta hai ye redeclare ho sakta hai by mistake

    const c = "This is the constant";

    // c = " test This is the constant";

    // console.log(c);


    // conditional statement

    var age = 45;

    if(age > 45){

        console.log("you are drink");

    }else if(age == 45){

        console.log("You are drink aur water both");

    }else{

        console.log("you are not allowed to drink")

    }

// switch case in the javascript


var sppons = 20;

switch (sppons) {

    case 12:

        console.log("The sppons is 12")

        break;

    case 14:

        console.log("The sppons is 14")

        break;

    case 16:

        console.log("The sppons is 16")

        break;

    case 18:

        console.log("The sppons is 18")

        break;

    case 20:

        console.log("The sppons is 20")

        break;

       

        default:

        console.log("The sppons is e of the above")

        break;

}

</script>

<body>

    <div class="container">

        <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Rem aperiam porro dolorum fugit atque commodi voluptatibus velit ipsum possimus animi.</p>

    </div>

</body>

</html>

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)