“делать, пока JavaScript” Ответ

JavaScript, пока

var i=0;
while (i < 10) {
	console.log(i);
	i++;
}
//Alternatively, You could  break out of a loop like so:
var i=0;
while(true){
	i++;
	if(i===3){
		break;
	}
}
Grepper

в то время как петля JavaScript

while (condition) {
	// code
}

// example
let index = 0;

while (index < 10) {
    // code
    index++;
}

//  enjoy :)
Odd Octopus

В то время как VS DO, пока JavaScript

// while vs do...while loops

/* while loops: check condition first. If true, execute code. */
let i = 0; 
while (i < 5) {
  console.log(i); // 0 1 2 3 4
   i += 1;
}

/* do-while loops: execute code at least once even if condition is false. 
Then check condition. If true, continue executing code. */
let j = 6;
do {
  console.log(j); // 6
    j += 1;
} while (j < 5);
Intra

делать, пока JavaScript

do {
  //whatever
} while (conditional);
slohobo

делать, пока JavaScript

let arr = ['jan', 'feb', 'mar', 'apr', 'may'], i = 0;
// do something at least 1 time even if the condition is false
do{
	console.log(arr[i]);
	i++;
}while(arr.includes('dec'));
// output: jan 
Felipe Lullio

делать, пока JavaScript

var i = 0;
do {
  text += "The number is " + i;
  i++;
}
while (i < 5);
Encouraging Eagle

Ответы похожие на “делать, пока JavaScript”

Вопросы похожие на “делать, пока JavaScript”

Смотреть популярные ответы по языку

Смотреть другие языки программирования