We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58d8705 commit 9a745cdCopy full SHA for 9a745cd
palindrome.js
@@ -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