How can I write this IF condition. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I write this IF condition.

While using an if statement, I want to write a condition "If an input is a number". How can I write it as a condition in if statement. Can anyone tell me what the code will be.

28th Jul 2019, 9:50 AM
Noor
Noor - avatar
3 Answers
+ 1
Set the input to a variable. Then use google to find the name of the method that checks if a variable is a number. Should be something like .isNumber() but not sure of the name.
29th Jul 2019, 7:25 AM
Frenchtoast
Frenchtoast - avatar
0
Thanks for your help. I found a method isInteger(). I hope it'll solve my problem.
29th Jul 2019, 7:38 AM
Noor
Noor - avatar
0
Should work.
29th Jul 2019, 7:39 AM
Frenchtoast
Frenchtoast - avatar