Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js while continue

let i = 0;
let n = 0;

while (i < 5) {
  i++;

  if (i === 3) {
    continue;
  }

  n += i;
}
Comment

javascript continue with for Loop

// program to print the value of i
for (let i = 1; i <= 5; i++) {

    // condition to continue    
    if (i == 3) {
        continue;
    }

    console.log(i);
}
Comment

how to use continue is js

for (var i = 0; i < 10; i++) {
if (i == 5) { continue; }       // skips the rest of the cycle
document.write(i + ", ");       // skips 5
}
Comment

javascript continue with while Loop

// program to calculate positive numbers only
// if the user enters a negative number, that number is skipped from calculation

// negative number -> loop terminate
// non-numeric character -> skip iteration

let sum = 0;
let number = 0;

while (number >= 0) {

    // add all positive numbers
    sum += number;

    // take input from the user
    number = parseInt(prompt('Enter a number: '));

    // continue condition
    if (isNaN(number)) {
        console.log('You entered a string.');
        number = 0; // the value of number is made 0 again
        continue;
    }

}

// display the sum
console.log(`The sum is ${sum}.`);
Comment

Continue in Javascript Loops

for (let i = 1; i <= 10; i++) {
    if (i == 3 || i == 7) {
        continue;
    }
    console.log(i);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript pass this to callback 
Javascript :: dom 
Javascript :: javascript get width of image 
Javascript :: nextjs markdown 
Javascript :: firebase realtime database javascript 
Javascript :: deploy node app to heroku 
Javascript :: js exports 
Javascript :: array count in mongoose query 
Javascript :: samoglasnici-vowels 
Javascript :: How do I use for-loops js 
Javascript :: aws lambda function setup for node js 
Javascript :: destructuring an array 
Javascript :: project to do with javascript 
Javascript :: javascript loop object key value 
Javascript :: mongoose query object 
Javascript :: how to take last element of array javascript 
Javascript :: vue prop using variable 
Javascript :: react-datepicker 
Javascript :: code splitting react 
Javascript :: js compiler 
Javascript :: radio button in reactive forms angular material 
Javascript :: javascript prototype inheritance 
Javascript :: node.js modules 
Javascript :: status discored jks 
Javascript :: javascript get all hidden elements 
Javascript :: how to display ä in js 
Javascript :: composer run command problem 
Javascript :: relative path vs absolute path javascript 
Javascript :: stop monitorevents 
Javascript :: jhipster success alert 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =