switch/case with numeric range
int i = 63;
switch (i)
{
case int n when (n >= 100):
Console.WriteLine($"I am 100 or above: {n}");
break;
case int n when (n < 100 && n >= 50 ):
Console.WriteLine($"I am between 99 and 50: {n}");
break;
case int n when (n < 50):
Console.WriteLine($"I am less than 50: {n}");
break;
}function getCategory(age) {
var category = "";
switch (true) {
case isNaN(age):
category = "not an age";
break;
case (age >= 50):
category = "Old";
break;
case (age <= 20):
category = "Baby";
break;
default:
category = "Young";
break;
};
return category;
}
getCategory(5); // will return "Baby"
Also in JavaScript:
- express router middleware
- material ui grid react
- javascript random number between 0 and 10
- godot destroy node
- Please update your node with version 8.11.3 or greater (but not version 10)
- how to use the map method in javascript
- component unmount useeffect
- $('#mymodal').modal('show') not working
- js random number
- angular build production
- javascript redirect with extra url arguments
- close exit app react native
- javascript change color
- the rest operator javascript
- javascript array map stack
- initialize a map js
- jquery get current row value
- list pci express version command line
- async await anonymous function
- javascript for loop starting from end
- how to remove name in react navigation header
- how to add button in javascript
- javascript fetch json
- align left text in reactstrap