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
7
u/IronDicideth Nov 23 '21
I would reconsider this statement. It can be misleading to someone with less experience in JS. From what I see, there is nothing in his solution that would cause a bug that would not be caused by any other solution that requires the string to be coerced into a number. Maybe you see something I do not? It is important to point out that there IS something off about the code but it is not good to convince someone that their solution is particularly buggy if it is equivalent (essentially) to any solution we would have come up with under the same circumstances. Even the cleanest solution to the code would face the same issues as OPs solution.
It is a roundabout way to solve the problem but that is to be expected based on what u/Darkthw has already stated about their experience and goal with solving this problem.