Do while loop in javascript

Asked
Active3 hr before
Viewed126 times

3 Answers

javascript
90%

while — loops through a block of code as long as the condition specified evaluates to true,,do…while — loops through a block of code once; then the condition is evaluated

Example_snippet/controller/utility/_javascript.js/ var i = 1; while(i <= 5) { . . .
var i = 1;
while(i <= 5) {    
    document.write("<p>The number is " + i + "</p>");
    i++;
}
load more v
88%

The do,

Example_snippet/controller/utility/_javascript.js/ do statement while (conditi. . .
do
   statement
while (condition);
load more v
72%

The do-while loop statement creates a loop that executes a block of code until a test condition evaluates to false,,In this tutorial, you have learned how to use the do-while loop statement to create a post-test loop that allows the body of the loop to execute at least one and to execute until the test condition evaluates to false

Example_snippet/controller/utility/_model.js/ .wp-block-code { border: 0; . . .
.wp - block - code {
      border: 0;
      padding: 0;
   }

   .wp - block - code > div {
      overflow: auto;
   }

   .shcb - language {
      border: 0;
      clip: rect(1 px, 1 px, 1 px, 1 px); -
      webkit - clip - path: inset(50 % );
      clip - path: inset(50 % );
      height: 1 px;
      margin: -1 px;
      overflow: hidden;
      padding: 0;
      position: absolute;
      width: 1 px;
      word - wrap: normal;
      word - break: normal;
   }

   .hljs {
      box - sizing: border - box;
   }

   .hljs.shcb - code - table {
      display: table;
      width: 100 % ;
   }

   .hljs.shcb - code - table > .shcb - loc {
      color: inherit;
      display: table - row;
      width: 100 % ;
   }

   .hljs.shcb - code - table.shcb - loc > span {
      display: table - cell;
   }

   .wp - block - code code.hljs: not(.shcb - wrap - lines) {
      white - space: pre;
   }

   .wp - block - code code.hljs.shcb - wrap - lines {
      white - space: pre - wrap;
   }

   .hljs.shcb - line - numbers {
      border - spacing: 0;
      counter - reset: line;
   }

   .hljs.shcb - line - numbers > .shcb - loc {
      counter - increment: line;
   }

   .hljs.shcb - line - numbers.shcb - loc > span {
      padding - left: 0.75 em;
   }

   .hljs.shcb - line - numbers.shcb - loc::before {
      border - right: 1 px solid #ddd;
      content: counter(line);
      display: table - cell;
      padding: 0 0.75 em;
      text - align: right; -
      webkit - user - select: none; -
      moz - user - select: none; -
      ms - user - select: none;
      user - select: none;
      white - space: nowrap;
      width: 1 % ;
   }
do {
   statement(s);
} while (expression);
Code language: JavaScript(javascript)
load more v