Check for Palindromes...What should I do?

Check for Palindromes...What should I do?
0

#1

Hi,

I wonder what I should change to get my code right. Something is right, but something is still wrong also.

function palindrome(str) {
  // Good luck!
  str = (str.toLowerCase());
  console.log(str);
  console.log(str.replace(/\W/g, ''));
  return true;
}



palindrome("eye");


#2

You are not checking anything? You return true in all cases.


#3

I am really stuck with this.


#4

If the reversed version of string is the same as the original one - it’s a palindrome.


#5

In order to complete this challenge you have to do several things:

  1. Understand what a palindrome is. This is a string that reads the same starting from both sides.
    eye, madam, and kayak are palindromes.
  2. You have to find out how to reverse a string
  3. Finally, you have to check whether the reversed string equals the original input. Depending upon the result, return a boolean.
    You might want to read about String.prototype.split(), Array.prototype.reverse(), Array.prototype.join()
Summary
function isPalindrome (str) {
return str===str.split('').reverse().join('');