The 'while' loop

Published on: April 26, 2017

Welcome to the twenty-fourth Easy JavaScript tutorial, part of EasyProgramming.net. In this tutorial, we cover the "while" loop. 

If you haven't already, I would highly recommend that you watch my 'while' loop tutorial in C++. It's a very old tutorial, but it's still relevant because the syntax of a for loop in C++ is the exact same as JavaScript. 

The while loop works similarly to the for loop. It just has a different syntax and doesn't necessary have an end. Although that's not always a good idea. 

Syntax of the while loop:


  while (condition is true) {
    code to be executed
  }

To fork the fiddle and follow along: https://jsfiddle.net/easyjs/93mbaLvt/

 

Remember to checkout the Resources section below for associated downloadable content, JSFiddle links, and other resources. Watch the video and follow along!

Resources:



Comments: