• Saturday , 4 April 2020

#12 JavaScript Tutorial | While loop

Code Canyon



A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement. Once the expression becomes false, the loop terminates.
The while loop is primarily used when the number of iterations in not known in advanced and the iterations are based on some boolean condition.
Syntax –
1
2
3
4
while (boolean condition)
{
loop statements…
}
While loop starts with the checking of condition. If it evaluated to true, then the loop body statements are executed otherwise first statement following the loop is executed. For this reason it is also called Entry control loop
Once the condition is evaluated to true, the statements in the loop body are executed. Normally the statements contain an update value for the variable being processed for the next iteration.
When the condition becomes false, the loop terminates which marks the end of its life cycle
For Program code, info & more resources checkout this article – https://simplesnippets.tech/while-loop-in-javascript-control-statements-in-js/
Video by – Tanmay Sakpal
Simple Snippets Channel link – https://www.youtube.com/simplesnippets

Original source

3d Ocean

Related Posts

11 Comments

  1. swetha
    January 1, 2020 at 08:39

    Hi sir…while I'm trying to run this program….result is 5+x+…..
    I'm not getting the odd numbers…just value is printing for 5 times

  2. prabu mech
    January 1, 2020 at 08:39

    please make video for loop vs while loop in js

  3. puneet singh
    January 1, 2020 at 08:39

    we can do also like this var x=1;
    while(x<=10)
    {
    if(x%2==0)
    document.write();
    else
    document.write(x);
    x++;
    }

  4. Krishna Shejul
    January 1, 2020 at 08:39

    sir ur the osm no word how js help me………..thnx a lot sir

  5. Yogita Negi
    January 1, 2020 at 08:39

    great

  6. Akhilesh Yaduwanshi
    January 1, 2020 at 08:39

    Excellent Tanmay

  7. Technology concepts
    January 1, 2020 at 08:39

    Good example got for while sir

  8. Ashish
    January 1, 2020 at 08:39

    Sir how do we print output in new line ? What is command for it because h1 tag is too lengthy .. there is no any command like in Java println.. ???? If anyone then tell me sir !

  9. Ram Maheshwari
    January 1, 2020 at 08:39

    Amazing Tutorial by Simple Snippets

  10. Pradeep Kumar
    January 1, 2020 at 08:39

    great sir g

  11. kuldeep Kumar
    January 1, 2020 at 08:39

    First viewer, sir I want to be a Android App developer so what all I should be learn

Leave A Comment

You must be logged in to post a comment.