FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/JS Basics/scripts/loops.js at master · Ch-sriram/JavaScript · GitHub
Ch-sriram
/
JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
JS Basics
/
scripts
/
loops.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (35 loc) · 1.1 KB
Breadcrumbs
JavaScript
/
JS Basics
/
scripts
/
loops.js
Copy path
File metadata and controls
46 lines (35 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/********************************************************************************************
* Looping & Iteration
*/
// for loop
for
(
var
i
=
1
;
i
<=
10
;
++
i
)
{
console
.
log
(
i
)
;
}
console
.
log
(
"-----------------------------------------------------------"
)
;
for
(
var
i
=
1
;
i
<=
20
;
i
+=
2
)
{
console
.
log
(
i
)
;
}
console
.
log
(
"-----------------------------------------------------------"
)
;
var
john
=
[
"John"
,
"Smith"
,
1990
,
"teacher"
,
false
]
;
for
(
var
i
=
0
;
i
<
john
.
length
;
++
i
)
{
console
.
log
(
john
[
i
]
)
;
}
console
.
log
(
"-----------------------------------------------------------"
)
;
// the same above loop using while() loop
var
i
=
0
;
while
(
i
<
john
.
length
)
{
console
.
log
(
john
[
i
]
)
;
++
i
;
}
console
.
log
(
"-----------------------------------------------------------"
)
;
// continue statement
for
(
var
i
=
0
;
i
<
john
.
length
;
++
i
)
{
if
(
typeof
john
[
i
]
!==
'string'
)
continue
;
console
.
log
(
john
[
i
]
)
;
}
console
.
log
(
"-----------------------------------------------------------"
)
;
// break statement
for
(
var
i
=
0
;
i
<
john
.
length
;
++
i
)
{
if
(
typeof
john
[
i
]
===
'boolean'
)
break
;
console
.
log
(
john
[
i
]
)
;
}
Back
|
FazBrowse Home
|
New Git URL