Loops in javascript

technical talkiess
0

 Loops in javascript:- 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

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

    <title>Loops</title>

</head>

<body>

    <div class="container">

        <p>Loops ins javascript</p>

    </div>

    <script>

        var i = 0;

        // initisilizse ; condition ; increment

        for (var i = 0; i <4; i++) {

            // console.log(i);

        }



        let student = ['vishal','madan','dada','kaka','mama','suraj'];


        // for loop ka use aap array ko iterate karne ke liye bhi kar sakte ho


        for (let index = 0; index < student.length; index++) {

            var element = student[index];

            // console.log(`Hello Friends `+ element);

        }


        student.forEach(function f(element){

            // console.log(`Hello Friends `+ element + " Usiing the foreach loop in the javascript");

        });


        for(item of student){

            // console.log(`Hello Friends `+ item + "  For of loop");

        }


        let employee = {

            name :"Vishal",

            age:24,

            salary:5550000,

            address:"Cidco aurangabad"

        }

        // for in loop object ko iterate karne ke liye use hota hai

        for(item in employee){

            // console.log(`Hello ${item} is an employee is ${employee[item]}`);

        }



        // while loop


        j = 0;

        while(j<45){

            // console.log(j);

            j++;

        }


        d = 1;

        do{

            console.log("Do while loop in javascript ");

            d++;

        }while(d<4);

    </script>

</body>

</html>

Post a Comment

0Comments

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

Post a Comment (0)