Yelp Interview Question

Given a string how would you check if the string is a palindrome?

Interview Answers

Anonymous

Feb 22, 2016

In Python: string == string[::-1]

1

Anonymous

Jul 1, 2016

function isPalindrome(str) { if (str.length == 0) console.log("No string given") var newstr=str.toLowerCase().split(" ").join(""); newstr = newstr.split("").reverse().join(""); if(str == newstr) console.log("Palindrome"); else console.log("Not a Palindrome"); } isPalindrome("hello world"); isPalindrome("poop");