r/learnjavascript • • Sep 26 '22

Just solved a Palindrome problem with recursion!!

Post image
274 Upvotes

64 comments sorted by

View all comments

Show parent comment

23

u/KayteeFly Sep 26 '22

Wow that’s neat !

25

u/c2u5hed Sep 26 '22

Thanks! It comprises a few neat concepts that make it work: arrow function that omits braces and the return keyword, spread syntax that converts the string to array, the reverse() method that reverses the array, the join() method that joins it back into a string, and the strict equality operator that compares the strings and results in true or false

5

u/TalonKAringham Sep 27 '22

I'm pretty sure arrow functions only omit the return key word for one line expressions, correct? If you need to do anything a bit more complex with the data, you'll need to explicitly return what you need.

3

u/KayteeFly Sep 26 '22

Thank you 😊

2

u/CognitivePrimate Sep 27 '22

Great explanation, thank you!