FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JS-Training/Algorithm training/Script1.js at master · PeterPanker/JS-Training · GitHub
PeterPanker
/
JS-Training
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
JS-Training
/
Algorithm training
/
Script1.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (34 loc) · 977 Bytes
Breadcrumbs
JS-Training
/
Algorithm training
/
Script1.js
Copy path
File metadata and controls
39 lines (34 loc) · 977 Bytes
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
// JavaScript source code
//palindrom = 1;
//i = 0;
//length = Math.floor((a.length - 1)/2);// # nus cum se scrie sa iei catul impartirii la 2;
//while (palindrom == 1 && i < length ) {
// if (a[i] === a[a.length - 1 - i]) {
// i++
// }
// else {
// palindrom = 0;
// }
//}
var
palindrom
=
1
;
var
confirmLimit
=
0
;
var
numberOfPalindromes
=
0
;
var
length
=
Math
.
floor
(
(
arr
.
length
-
1
)
/
2
)
;
var
tempArray
=
arr
.
slice
(
a
,
b
+
1
)
;
for
(
var
i
=
a
;
i
<
b
+
1
;
i
++
)
{
if
(
palindrom
==
1
&&
i
<
length
)
{
if
(
tempArray
[
i
]
==
tempArray
[
tempArray
.
length
-
i
]
)
{
confirmLimit
++
;
palindrom
=
1
;
if
(
confirmLimit
==
tempArray
.
length
)
{
numberOfPalindromes
++
;
palindromHolder
[
numberOfPalindromes
]
=
tempArray
;
}
}
else
{
palindrom
=
0
;
confirmLimit
=
0
;
}
}
}
console
.
log
(
palindromHolder
)
;
console
.
log
(
numberOfPalindromes
)
;
Back
|
FazBrowse Home
|
New Git URL