Javascript – for and while loops

Loops let you execute one block of code many times. There are three loops: for, while and do while

for loop

for (initialization; condition; incrementation) {
  statement(s)
}
, <span>Javascript – for and while loops</span>, KandZ
, <span>Javascript – for and while loops</span>, KandZ

for in loop – loops through an object’s properties

for (property) {
  statement(s)
}
, <span>Javascript – for and while loops</span>, KandZ
, <span>Javascript – for and while loops</span>, KandZ

for of loop – loops through values of an array, string or any other iterable object

for (variable){
   statement(s)
}
, <span>Javascript – for and while loops</span>, KandZ
, <span>Javascript – for and while loops</span>, KandZ

while loop

while (condition){
   statement(s)
}
, <span>Javascript – for and while loops</span>, KandZ

do while loop – the code of block will be executed at least one time

do {
   statement(s)
} while (condition);
, <span>Javascript – for and while loops</span>, KandZ

continue statement stops the block execution for one iteration and continues the iterations

, <span>Javascript – for and while loops</span>, KandZ
, <span>Javascript – for and while loops</span>, KandZ
2 is missing

break statement stops the iteration

, <span>Javascript – for and while loops</span>, KandZ
, <span>Javascript – for and while loops</span>, KandZ

THE END!!!

101640cookie-checkJavascript – for and while loopsJavascript – for and while loops

Related posts