DEV Community

Discussion on: Javascript Algorithms #2: Palindromes

Collapse
 
itsjzt profile image
Saurabh Sharma

those memories of solving algorithms at freecodecamp.org

const isPalindrome = str => str.toLowerCase() === str.toLowerCase().split().reverse().join() 

Collapse
 
worldclassdev profile image
Philip Obosi

Clean and concise

Collapse
 
mhmoodlan profile image
Mahmoud Aslan

nice, somehow didn't work until i added the splitters for split() and join()

const isPalindrome = str => str.toLowerCase() === str.split('').reverse().join('')
Collapse
 
worldclassdev profile image
Philip Obosi • Edited

Thanks for the save. I didn't even look at the syntax closely. It's still a pretty concise solution though

Collapse
 
itsjzt profile image
Saurabh Sharma

thats why we needs unit tests 😅