Skip to content

Commit 9a745cd

Browse files
committed
Palindrome Solution
1 parent 58d8705 commit 9a745cd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

palindrome.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Function checking if the string passed is a Palindrome
2+
3+
const Palindrome = (str) => {
4+
let noSpaces = str.replace(/ /g,"").toLowerCase();
5+
let backwards = noSpaces.split("").reverse().join("");
6+
return noSpaces == backwards;
7+
}
8+
console.log(Palindrome('raccar')) //true
9+
console.log(Palindrome('damn')) //false
10+
console.log(Palindrome(' Raccar ')) //true
11+
console.log(Palindrome('Boar')) //false

0 commit comments

Comments
 (0)