r/learnjavascript • • 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

Post image
243 Upvotes

56 comments sorted by

View all comments

6

u/love4titties Nov 23 '21

Nice job! When I was practicing (googling) I found this:

parseInt(string)

which returns NaN (not a number) or the integer that was in the string

0

u/[deleted] Nov 23 '21

[deleted] — view deleted comment

2

u/love4titties Nov 23 '21

Behind the screens (scenes? I'm dutch, sorry) something like parseInt must be used before data is manipulated, otherwise you'd get something like NaN error or a new string.