FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
secureCodeBox/documentation/src/utils/capitalizer.js at main · secureCodeBox/secureCodeBox · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
secureCodeBox
/
secureCodeBox
Public
Notifications
You must be signed in to change notification settings
Fork
183
Star
985
Code
Issues
62
Pull requests
4
Discussions
Actions
Projects
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
secureCodeBox
/
documentation
/
src
/
utils
/
capitalizer.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (25 loc) · 778 Bytes
Breadcrumbs
secureCodeBox
/
documentation
/
src
/
utils
/
capitalizer.js
Copy path
File metadata and controls
29 lines (25 loc) · 778 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
// SPDX-FileCopyrightText: the secureCodeBox authors
//
// SPDX-License-Identifier: Apache-2.0
function
capitalizeFirst
(
string
)
{
return
string
.
charAt
(
0
)
.
toUpperCase
(
)
+
string
.
slice
(
1
)
;
}
function
capitalizeEach
(
string
)
{
let
splitStr
=
string
.
toLowerCase
(
)
.
split
(
' '
)
;
for
(
var
i
=
0
;
i
<
splitStr
.
length
;
i
++
)
{
// You do not need to check if i is larger than splitStr length, as your for does that for you
// Assign it back to the array
splitStr
[
i
]
=
splitStr
[
i
]
.
charAt
(
0
)
.
toUpperCase
(
)
+
splitStr
[
i
]
.
substring
(
1
)
;
}
// Directly return the joined string
return
splitStr
.
join
(
' '
)
;
}
function
removeWhitespaces
(
string
)
{
return
string
.
replace
(
/
\\
s
+
/
g
,
''
)
;
}
module
.
exports
=
{
capitalizeFirst
,
capitalizeEach
,
removeWhitespaces
,
}
;
Back
|
FazBrowse Home
|
New Git URL