You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47Lines changed: 47 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2125,3 +2125,50 @@ const toCamel = obj => {
2125
2125
---
2126
2126
2127
2127
**[⬆ Back to Top](#javascript-coding-challenges-for-beginners)**
2128
+
2129
+
## 59. Valid Palindrome
2130
+
2131
+
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string `s`, return`true`if it is a palindrome, or `false` otherwise.
2132
+
2133
+
```js
2134
+
const isPalindrome = s => {
2135
+
// Your solution
2136
+
};
2137
+
2138
+
console.log(isPalindrome('A man, a plan, a canal: Panama')); // true
2139
+
// Explanation: "amanaplanacanalpanama" is a palindrome.
2140
+
console.log(isPalindrome('race a car')); // false
2141
+
// Explanation: "raceacar" is not a palindrome.
2142
+
console.log(isPalindrome('ab_a')); // true
2143
+
// Explanation: "aba" is a palindrome.
2144
+
console.log(isPalindrome('')); // true
2145
+
// Explanation: `s` is an empty string "" after removing non-alphanumeric characters.
2146
+
// Since an empty string reads the same forward and backward, it is a palindrome.
0 commit comments