MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/tinycode/comments/2i5n2t/palindrome_checker_in_javascript/ckzu5wa/?context=9999
r/tinycode • u/criveros • Oct 03 '14
12 comments sorted by
View all comments
14
Better JavaScript version:
var isPalindrome = function(string) {
return string == string.split("").reverse().join("");
};
And an awesome Haskell version:
palindrome s = s == reverse s
0 u/[deleted] Oct 03 '14 [deleted] 1 u/Toni_W Oct 03 '14 Split reverse join, it just explodes, reverses, implodes, and returns the comparison. 0 u/[deleted] Oct 03 '14 [deleted] 1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that.
0
[deleted]
1 u/Toni_W Oct 03 '14 Split reverse join, it just explodes, reverses, implodes, and returns the comparison. 0 u/[deleted] Oct 03 '14 [deleted] 1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that.
1
Split reverse join, it just explodes, reverses, implodes, and returns the comparison.
0 u/[deleted] Oct 03 '14 [deleted] 1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that.
1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that.
you're optimizing ahead of time by thinking like that.
14
u/peridox Oct 03 '14
Better JavaScript version:
var isPalindrome = function(string) {return string == string.split("").reverse().join("");};And an awesome Haskell version:
palindrome s = s == reverse s