We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7aa9dbd commit dad84dcCopy full SHA for dad84dc
Palindrome_Checker/script.js
@@ -0,0 +1,11 @@
1
+function palindrome(str) {
2
+ // use regex to replace non-string to nothing also changing all letters to lowercase
3
+ str = str.replace(/\W|_/g, "").toLowerCase();
4
+ // reverse each words by spliting them and joining them again
5
+ let reverse = str.split("").reverse().join("");
6
+ // compare if the reversed string is the same as the prior string. return true if that is true and false if it is not
7
+ if (reverse === str) return true
8
+ return false
9
+ }
10
+
11
+ palindrome("eye");
0 commit comments