Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Iterate with JavaScript While Loops

var ourArray = [];
var i = 0;
while(i < 5) {
  ourArray.push(i);
  i++;
} // 0 to 4 [ 0, 1, 2, 3, 4 ]

var myArray = [];
var i = 5;
while (i  >= 0) {
  myArray.push(i);
  i--;
} // 5 to 0 (reverse) [ 5, 4, 3, 2, 1, 0 ]
Comment

Iterate with Do While Loops Javascript

var myArray = [];

var i = 10;

 do {  // The do while loop will always run atleast once before checking the condtion. This will return false and break out of the loop.
	myArray.push(i);
    i++;
} while (i < 5)

console.log(i, myArray);
Comment

Iterate with JavaScript Do...While Loops

var ourArray = []; 
var i = 5;
do {
  ourArray.push(i);
  i++;
} while (i < 5); // it will work once and stop looping.
Comment

iterate with javascript while loops

var myArray = []



var i = 0;
while(i < 5){
    myArray.push(i)
    i++
}


console.log(myArray);
Comment

PREVIOUS NEXT
Code Example
Javascript :: make image onclick in vuejs 
Javascript :: unknown provider angularjs 
Javascript :: nodejs beautifulsoup 
Javascript :: array merge in javascript 
Javascript :: js new array 
Javascript :: change value on selected jquery 
Javascript :: node-fetch graphql 
Javascript :: node js 
Javascript :: react native radio buttons 
Javascript :: .push js 
Javascript :: find vowels in string javascript 
Javascript :: document.body.style.background 
Javascript :: Use jsx extension react-native 
Javascript :: array from javascript 
Javascript :: sort in javascript 
Javascript :: push method in javascript 
Javascript :: sequelize transaction 
Javascript :: nextjs local storage 
Javascript :: populate modal from table 
Javascript :: online password generator 
Javascript :: form serialize object javascript 
Javascript :: loop into array javascript 
Javascript :: string javascript concatenation 
Javascript :: prevent history back javascript 
Javascript :: difference between single quotes and double quotes in javascript 
Javascript :: how to change Mime type of a file express 
Javascript :: new function in javascript 
Javascript :: how to use the foreach fnction javascript loop through array 
Javascript :: Find items from object 
Javascript :: linked list algorithm javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =