0
Checking if input is empty?
How can I check if the input is empty for this code? I usually do something like this: if(number == "") { //Code to execute } But that doesn't seem to work if a space or multiple spaces is present. For example, add that to the code, then input a space and press the button. It returns "is divisible by 2." I'd have to individually add each number of spaces. Is there a way around this? https://code.sololearn.com/W71keXUbAKcL/#html
3 Answers
+ 2
if(number.trim() === "") {
//Code to execute
}
0
Use
number.trim()
0
Can I have an example? I have no idea where to put that xD
amnotsmart