Frage im Vorstellungsgespräch bei Insight Global

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

Antworten zu Vorstellungsgespräch

Anonym

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

Anonym

2. Nov. 2017

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

Anonym

8. Mai 2021

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

Anonym

15. Nov. 2012

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

1