how to use switch case in javascript
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}//javascript multiple case switch statement
var color = "yellow";
var darkOrLight="";
switch(color) {
case "yellow":case "pink":case "orange":
darkOrLight = "Light";
break;
case "blue":case "purple":case "brown":
darkOrLight = "Dark";
break;
default:
darkOrLight = "Unknown";
}
//darkOrLight="Light"var Animal = 'Giraffe';
switch (Animal) {
case 'Cow':
case 'Giraffe':
case 'Dog':
case 'Pig':
console.log('This animal will go on Noah\'s Ark.');
break;
case 'Dinosaur':
default:
console.log('This animal will not.');
}switch (expression) {
case value1:
//Statements executed when the
//result of expression matches value1
[break;]
case value2:
//Statements executed when the
//result of expression matches value2
[break;]
...
case valueN:
//Statements executed when the
//result of expression matches valueN
[break;]
[default:
//Statements executed when none of
//the values match the value of the expression
[break;]]
}
Also in JavaScript:
- check if isset variable js
- string to JSONobject + android
- npm ERR! Unexpected end of JSON input while parsing near '...ty":"sha512-2GTXt3b2Q'
- react set title of page
- jquery bind function to multiple events
- javascript is undefined
- Getting Nan when calculate two date js
- js string explode
- how to create my own filter in js
- on click fade out jquery
- react native modal
- vscode tab size
- axios js
- import npm module node.js
- display time in html using javascript
- gatsby guess
- List more than 30 students in a class in Google Classroom API query Ask Question
- ajax data post call in javascript
- enzyme test method
- convert image url to base64 javascript
- clean collection mongoose
- how to print numbers in javascript
- how to remove a property from an object in javascript
- You need to inject a global window.jQuery first.