Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

while and do while loop in javascript

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
//  while loop
 let j= 0;
 while(j < arr.length)
 {
     console.log(arr[j]);
     j++;
 }

//do-while loop
 let k=0;
 do{
     console.log(arr[k]);
     k++;
 }
 while(k < arr.length);
 
PREVIOUS NEXT
Tagged: #loop #javascript
ADD COMMENT
Topic
Name
8+9 =