Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
palindorm_checker_fcc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cedric Skwar
palindorm_checker_fcc
Commits
1218dbf9
Commit
1218dbf9
authored
2 years ago
by
Cédric Skwar
Browse files
Options
Downloads
Patches
Plain Diff
Finished the problem
parents
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.js
+24
-0
24 additions, 0 deletions
main.js
with
24 additions
and
0 deletions
main.js
0 → 100644
+
24
−
0
View file @
1218dbf9
function
palindrome
(
str
)
{
str
=
str
.
replace
(
/
[^
a-z0-9
]
/gi
,
''
)
// Remove non alpha numeric values
str
=
str
.
toLowerCase
()
// Convert it to the same case
let
str_reversed
=
str
.
split
(
""
)
// Firstly convert the str to an array
str_reversed
=
str_reversed
.
reverse
()
// Reverse the array with the reverse function
str_reversed
=
str_reversed
.
join
(
""
)
// Finally join the reversed str back together
return
str_reversed
===
str
// Check if the reversed string is same as the input if so, it returns true
}
// Tests Below
/*
palindrome("eye"); // True
palindrome("_eye") // True
palindrome("not a palindrome") // False
palindrome("A man, a plan, a canal. Panama"); // True
palindrome("never odd or even") // True
palindrome("nope") // False
palindrome("almostomla") // False
palindrome("My age is 0, 0 si ega ym.") // True
palindrome("1 eye for of 1 eye.") // False
palindrome("0_0 (: /-\ :) 0-0") // True
palindrome("five|\_/|four") // False
*/
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment