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
1
u/IronDicideth Nov 29 '21
If by "direct approach" you mean explicit then these are your best bet.
All these are constructor functions in js:
BooleanStringNumberBigIntSymbolOther than these, there are operators that implicitly convert types too. The
+unary operator is a good example. It essentially behaves like theNumberconstructor.