Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript uses switch/case when judging the range of values

Shulou Source: shulou.com Published: 2022-06-01 05:41:21 11月14日 Update

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)

Tags: Value range article value interest at the same time situation time more friends knowledge editing industry information information channel face channel reference learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia Redmi MariaDB MySQL