Is there a symbol for infinity in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there a symbol for infinity in JavaScript?

I want to create an if else command where if the input value is any number 0 through infinity it will carry out as planned. What should I do?

8th May 2017, 12:01 AM
Ben Galbraith
3 Answers
+ 8
Simply test if the value is greater than zero: var test = 42; if ( test >= 0 ) { // do something } else { // do another thing }
8th May 2017, 12:05 AM
visph
visph - avatar
+ 6
Yes, it's Infinity.
8th May 2017, 12:04 AM
Karl T.
Karl T. - avatar
0
Thank you so much!
8th May 2017, 12:06 AM
Ben Galbraith