How JavaScript uses switch/case when judging the range of values
This article mainly introduces JavaScript how to judge the range of values when using switch/case, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Use switch/case when determining the range of values
In the following cases, it is reasonable to use switch/case to determine the range of values:
Function getCategory (age) {var category = ""; switch (true) {case isNaN (age): category = "not an age"; break; case (age > = 50): category = "Old"; break; case (age)