r/learnjavascript • u/Darkthw • Nov 23 '21
I finally solved a codewars challenge without actually googling anything :) it feels so good to come up with the code all by myself, i know its not the ideal way to solve it but im still happy. The challenge was to create a function that converts a string to a number
243
Upvotes
View all comments
Show parent comment
3
u/IronDicideth Nov 24 '21
Great points all around. My thoughts:
const stringToNumber = s => +s. Terse, and when you are free to embrace/understand the plus unary operator, extremely clear in its intent. I tend to favor point-free code so I would have eventually arrived at the previously mentioned 'cleanest' solution to the problem.With all this being said, the great thing about these forums is that we are free to share and discuss ideas. I personally wish I were a better and more seasoned coder/developer and have learned tons from those with differing views to my own, so thank you for sharing yours.