|
|
|
|
|
by verroq
3676 days ago
|
|
I'd expect to see this (assuming that this guy is a Javascript shop). function isPalindrome(str) {
for (let i = 0; i < str.length / 2; i++) {
if (str[i] !== str[str.length - i - 1]) {
return false;
}
}
return true;
}
Quick check list:1. Knows about es6 2. Knows about === and !== 3. O(n) efficiency with no memory bloat 4. Didn't write 30+ lines on a trivial function I won't even add a comment about unicode since it should be your default assumption when working with javascript that multi-byte characters and surrogate pairs don't work properly. |
|
You need to ignore white space and punctuation.
6. Didn't include any tests
7. Bonus! This function also returns true if you pass it a palindromic array! Er... Maybe it shouldn't do that.