4 ms·
Honestly; the example answer is not good. If I was in a hiring position, I would at least talk to the person writing this and ask them to change their style. T
by chvid 10y ago
Honestly; the example answer is not good. If I was in a hiring position, I would at least talk to the person writing this and ask them to change their style.
The problem is that the answer is slightly over-engineered, over-commented, checks for input type, logs in a corner-case, looks-like-it-has-been-written-by-a-teacher-with-too-much-time-on-their-hands.
These are not problems in themselves but when you have a new person on the team and they write code like that, it may be inconsistent with what the rest of the team is doing / what the rest of code base looks like.
For comparison here is another way to test for a palindrome:
function isPalindrome(text) {
for (var i = 0; i <= text.length / 2; i++) {
if (text[i] != text[text.length - i - 1]) return false;
}
return true;
}
(Possibly add "normalization" in the beginning as they do in the article.)
- Clubber 10y agoHah. I was thinking that too. While I was reading the article, I was thinking about how I would do it. Then I read the wall of text that was the ideal solutions and thought, "wow, what the hell are coders doing these days?"