FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Problem-solving-with-JavaScript/problem-23.js at master · anasmak04/Problem-solving-with-JavaScript · GitHub
anasmak04
/
Problem-solving-with-JavaScript
Public
forked from
mehediislamripon/Problem-solving-with-JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Problem-solving-with-JavaScript
/
problem-23.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (16 loc) · 450 Bytes
Breadcrumbs
Problem-solving-with-JavaScript
/
problem-23.js
Copy path
File metadata and controls
21 lines (16 loc) · 450 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
/**
* Let us create a function that receives a string "abcbdbd",
* and returns an array like:
["a", "a.b", "a.b.c", "a.b.c.b", "a.b.c.b.d", "a.b.c.b.d.b", ...]
*/
const
str
=
'abcbdbd'
;
function
splitString
(
str
)
{
const
arr
=
str
.
split
(
''
)
;
let
tempArr
=
[
]
;
for
(
let
i
=
1
;
i
<
arr
.
length
;
i
++
)
{
let
cutArray
=
arr
.
slice
(
0
,
i
)
.
join
(
'.'
)
;
tempArr
.
push
(
cutArray
)
;
}
return
tempArr
;
}
console
.
log
(
splitString
(
str
)
)
;
Back
|
FazBrowse Home
|
New Git URL