Can I please get the link of the next video you are referring to?
@MisterBrash2 жыл бұрын
I don't believe I ever made a follow-up video to this one. This was a video I made for a class back in 2020 but essentially you want to use an if-statement and the isNaN( ) function. The isNaN( ) function will return TRUE if the input is NOT a number. A bit confusing, but let's say you have a variable "input" and you want to know if the variable is NOT a number - you have two choices (there are more but these are easy). Option A: if (typeof input != 'number') this will return true if the variable is NaN. Option B: if (isNaN(input)) This does the same thing. Seeing code like this in a KZbin comment is difficult, I know, but do some Googling for isNaN( ) and using if-statements to check if a variable is a number or not.
@benzona15032 жыл бұрын
clean af 🤌
@yayeettt3 жыл бұрын
in short use parseInt :D
@MisterBrash3 жыл бұрын
Sure - but this was for my intro to programming class that I teach at a high school (14 years-old). So we take it very slowly and learn in small chunks. This particular video was specifically in response to some questions I was receiving as we learned how to receive input from the user. Now in terms of your comment about "just use parseInt" that's also not exactly true because it would depend on what you are trying to gather from the user. For example - what if you don't specifically want a whole number? What if you are allowing decimals? People who know JavaScript tend to say "Just do this" but it doesn't explain WHY. The goal when teaching someone is not to give blanket "just do" statements. It's important that people understand the WHY or they'll just use that thing and not really understand the point behind it.
@yayeettt3 жыл бұрын
@@MisterBrash oh yeah I totally understand tho i have teacher that does that 🤔
@osmalflopez887711 ай бұрын
True teacher response. My math teachers hated me for asking why to everything, but that's the only way to truly understand what you're doing and actually learn.@@MisterBrash