Skip to content

Instantly share code, notes, and snippets.

@walidmahade
Created October 23, 2020 17:28
Show Gist options
  • Save walidmahade/85ac36eaca983f81f5fd0bf3587148a2 to your computer and use it in GitHub Desktop.
Save walidmahade/85ac36eaca983f81f5fd0bf3587148a2 to your computer and use it in GitHub Desktop.
let a = 10; // save 10 inside varialbe 'a'
let x = 0; // // save 0 inside varialbe 'x'
while(x < a) { // condition is - as long as value of 'x' is less than value of 'a', we will run the following code
console.log( x ); // print current value of 'x' to the console
x = x + 1 // then, add 1 to current value of 'x'
}
/*
That loop will run 11 times and print -
0
1
2
3
4
5
6
7
8
9
10
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment