#12 JavaScript Tutorial | While loop

preview_player
Показать описание
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
Video by - Tanmay Sakpal
Рекомендации по теме
Комментарии
Автор

Hello Sir,
I am not getting the exact difference between for loop and while loop? Through the example, you have shown in both videos it's considering as same for me. Please guide here.

rishia
Автор

What if want to print till 15 then what we need to change in this code.

_krish_fitness_
Автор

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 !

Ashish-wdod
Автор

good morning brooo why should we write all these only in script tag only
can we write all these loopings and swich cases in body tag?

anjusCodeWorld
Автор

sir ur the osm no word how js help a lot sir

krishnashejul
Автор

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

Abhisheksingh-udht
Автор

please make video for loop vs while loop in js

prabu
Автор

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

kuldeepKumar-plmk
Автор

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

Swethaundapalli