-
Notifications
You must be signed in to change notification settings - Fork 0
/
break-continue.js
59 lines (40 loc) · 864 Bytes
/
break-continue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//print elements from 1 to 10 except 5
for( let i=1;i<=10;i++)
{
if(i==5)
continue; // continue skips the next part of the current iteration and
//continues to next iteration
console.log(i)
}
//print 10-20 , stop if a multiple of 7 is encountered
for(let i=10 ;i<=20;i++)
{
if(i%7==0)
{ console.log(i , "is a multiple of 7 ");
break;
}
else
{
console.log(i);
}
}
//Javascript Lables*******************************************
let str= '';
console.log(" continue statement using labels")
loop1:
for (let i = 0; i < 5; i++) {
if (i === 2) {
continue loop1;
}
str = str + i;
}
console.log("The string is " , str);
//Break using labels
console.log(" break statement using labels")
let z=15;
label2:
for(let i=10 ;i <=20;i++)
{ if (i===z)
break label2;
console.log(i);
}