DEV Community 👩‍💻👨‍💻

Discussion on: JavaScript Struggles - Part 2 | Numbers

abdelrahman_dwedar profile image
‘Abdelraḥman Dwedar 👨🏻‍💻🇵🇸 Author

I know all of those, but I wanted to explain them in simple way and examples.
So I meant to do the wrong way so I show that it's wrong and explain the right way and the reason for it as much as I could.

null is not a number but when we set it as the value of the variable if we increased it, it'll be 1.

The last one I already said in the article right here ↴

I hope you read the article carefully again. 😊

lukeshiru profile image
Luke Shiru

I did read it carefully, it is still wrong. If you add 1 to null, null being falsy when casted to number returns 0, so adding 1 obviously returns 1.

You might want to consider actually learning about how types work in JS before "explaining it" 😑

Thread Thread
abdelrahman_dwedar profile image
‘Abdelraḥman Dwedar 👨🏻‍💻🇵🇸 Author

I didn't mean that null is number buddy. and I just added null not because it's a number, it was because people think it's equal to 0 and then get confused when it doesn't equal.

And thanks for clarifying those topics that I didn't cover.