Interview Question

Junior Java Developer Interview

-Philadelphia, PA

Insight Global

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

Answer

Interview Answers

4 Answers

2

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

0

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

Anonymous on

0

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

Anonymous on

1

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.