Break and continue statements and while loops


//While loops are the loops that keeps on repeating itself until the condition is false

// while(condition){
// //code to be executed
// }

//1 to 10
var x =1;
while(x<=10){
console.log(x);
x++;
}
for(var i = 31; i<=40;i++){
console.log(i);
}

//you want to stop the code at 38
for(var i = 31; i<=40;i++){
console.log(i);
if(i==38){
break; // come out of the loop
}
}
//continue statements - helps you skip a value in a loop

// 1 to 10 --- skip value 7

var a = 0;
while (a<=10){
a++;
if(a == 7){
continue;
}
console.log(a);
}
for(let i = 0; i < 5; i++) {
if (i == 3) {
continue;
}
console.log(i);
}
let number = (prompt("Enter a even number:"));

for(let i = 0; i <= number; i++) {
console.log(i);

if(i == (number / 2)) {
break;
}
}