Insight Global interview question

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

Interview Answers

Anonymous

2 Nov 2017

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.

2

Anonymous

2 Nov 2017

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

Anonymous

8 May 2021

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

Anonymous

15 Nov 2012

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

1