Interview Question

Junior Java Developer Interview

-Philadelphia, PA

Insight Global

Implement a method to determine whether a string is a palindrome.

AnswerAdd Tags

Interview Answers

4 Answers


Take a string as function parameter. Copy this str value into a new var, then use .reverse() thereupon. Compare the reversed copy back against original string using turnery operator to set resVariable to "true" : "false". Return resVariable.

Anonymous on


(Using .split(""), as well as .join(""))

Anonymous on


const palindrome = (str) => str == str.reversed() palindrome('hello') // false palindrome('eve') // true

Anonymous on


Recursive method; start from the ends and work your way in. Use indices if worried about memory.

Anonymous on

Add Answers or Comments

To comment on this, Sign In or Sign Up.