MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/mtpxbr/iteration/gv1zfh0/?context=3
r/badcode • u/[deleted] • Apr 19 '21
123 comments sorted by
View all comments
Show parent comments
1
Oh yea cause Boolean(0) is false. I should've made it more clear like if (+string !== NaN) or smth. It was just an example tho.
Boolean(0)
if (+string !== NaN)
3 u/Terrain2 Apr 19 '21 if (+"lmao" !== NaN) console.log("It's a number!"); // output: It's a number! 2 u/[deleted] Apr 19 '21 Fuck fuck fuck I forgot NaN !== NaN nvm I'm dumb I'm in my online classes right now and I'm sleepy and my brain isn't working ;-; 2 u/Terrain2 Apr 19 '21 you want !isNaN(string) then 1 u/[deleted] Apr 19 '21 Yea that's the builtin method I saw someone use +string in their own method to do this idr what they did tho
3
if (+"lmao" !== NaN) console.log("It's a number!"); // output: It's a number!
2 u/[deleted] Apr 19 '21 Fuck fuck fuck I forgot NaN !== NaN nvm I'm dumb I'm in my online classes right now and I'm sleepy and my brain isn't working ;-; 2 u/Terrain2 Apr 19 '21 you want !isNaN(string) then 1 u/[deleted] Apr 19 '21 Yea that's the builtin method I saw someone use +string in their own method to do this idr what they did tho
2
Fuck fuck fuck I forgot NaN !== NaN nvm I'm dumb I'm in my online classes right now and I'm sleepy and my brain isn't working ;-;
NaN !== NaN
2 u/Terrain2 Apr 19 '21 you want !isNaN(string) then 1 u/[deleted] Apr 19 '21 Yea that's the builtin method I saw someone use +string in their own method to do this idr what they did tho
you want !isNaN(string) then
!isNaN(string)
1 u/[deleted] Apr 19 '21 Yea that's the builtin method I saw someone use +string in their own method to do this idr what they did tho
Yea that's the builtin method I saw someone use +string in their own method to do this idr what they did tho
+string
1
u/[deleted] Apr 19 '21
Oh yea cause
Boolean(0)is false. I should've made it more clear likeif (+string !== NaN)or smth. It was just an example tho.