2018-10-04 14:37:37 +01:00
---
id: aaa48de84e1ecc7c742e1124
title: Palindrome Checker
challengeType: 5
2019-07-31 11:32:23 -07:00
forumTopicId: 16004
2018-10-04 14:37:37 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
Return `true` if the given string is a palindrome. Otherwise, return `false` .
2018-10-04 14:37:37 +01:00
A < dfn > palindrome< / dfn > is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
2020-11-27 19:02:05 +01:00
**Note:** You'll need to remove **all non-alphanumeric characters** (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.
We'll pass strings with varying formats, such as `"racecar"` , `"RaceCar"` , and `"race CAR"` among others.
We'll also pass strings with special symbols, such as `"2A3*3a2"` , `"2A3 3a2"` , and `"2_A3*3#A2"` .
# --hints--
`palindrome("eye")` should return a boolean.
```js
assert(typeof palindrome('eye') === 'boolean');
2018-10-04 14:37:37 +01:00
```
2020-11-27 19:02:05 +01:00
`palindrome("eye")` should return true.
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(palindrome('eye') === true);
```
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
`palindrome("_eye")` should return true.
2018-10-04 14:37:37 +01:00
```js
2020-11-27 19:02:05 +01:00
assert(palindrome('_eye') === true);
```
`palindrome("race car")` should return true.
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(palindrome('race car') === true);
```
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
`palindrome("not a palindrome")` should return false.
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(palindrome('not a palindrome') === false);
2018-10-04 14:37:37 +01:00
```
2020-11-27 19:02:05 +01:00
`palindrome("A man, a plan, a canal. Panama")` should return true.
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(palindrome('A man, a plan, a canal. Panama') === true);
```
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
`palindrome("never odd or even")` should return true.
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(palindrome('never odd or even') === true);
```
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
`palindrome("nope")` should return false.
```js
assert(palindrome('nope') === false);
```
`palindrome("almostomla")` should return false.
```js
assert(palindrome('almostomla') === false);
```
2018-10-04 14:37:37 +01:00
2020-11-27 19:02:05 +01:00
`palindrome("My age is 0, 0 si ega ym.")` should return true.
```js
assert(palindrome('My age is 0, 0 si ega ym.') === true);
```
`palindrome("1 eye for of 1 eye.")` should return false.
```js
assert(palindrome('1 eye for of 1 eye.') === false);
```
`palindrome("0_0 (: /-\ :) 0-0")` should return true.
```js
assert(palindrome('0_0 (: /- :) 0-0') === true);
```
`palindrome("five|\_/|four")` should return false.
```js
assert(palindrome('five|_/|four') === false);
```
# --seed--
## --seed-contents--
```js
function palindrome(str) {
return true;
}
palindrome("eye");
```
# --solutions--
2018-10-04 14:37:37 +01:00
```js
function palindrome(str) {
var string = str.toLowerCase().split(/[^A-Za-z0-9]/gi).join('');
var aux = string.split('');
if (aux.join('') === aux.reverse().join('')){
return true;
}
return false;
}
```