1 parent 9bfd527 commit 295429cCopy full SHA for 295429c
1 file changed
palindrome.js
@@ -0,0 +1,12 @@
1
+// filename: palindrome.js
2
+// Run: node palindrome.js racecar
3
+const input = process.argv[2];
4
+if (!input) {
5
+ console.log("Usage: node palindrome.js <string>");
6
+ process.exit(1);
7
+}
8
+function isPalindrome(str) {
9
+ const cleaned = str.toLowerCase().replace(/[^a-z0-9]/g, "");
10
+ return cleaned === cleaned.split("").reverse().join("");
11
12
+console.log(`${input} → ${isPalindrome(input) ? "Palindrome" : "Not Palindrome"}`);
0 commit comments