write the syntax of switch statement.
SagnikPradhan:
In which Language...?
Answers
Answered by
3
var expr = 'Papayas';
switch (expr) {
case 'Oranges':
console.log('Oranges are $0.59 a pound.');
break;
case 'Mangoes':
case 'Papayas':
console.log('Mangoes and papayas are $2.79 a pound.');
// expected output: "Mangoes and papayas are $2.79 a pound."
break;
default:
console.log('Sorry, we are out of ' + expr +'.');
}
switch (expr) {
case 'Oranges':
console.log('Oranges are $0.59 a pound.');
break;
case 'Mangoes':
case 'Papayas':
console.log('Mangoes and papayas are $2.79 a pound.');
// expected output: "Mangoes and papayas are $2.79 a pound."
break;
default:
console.log('Sorry, we are out of ' + expr +'.');
}
Answered by
6
Dear friend,
The syntax of switch statement is:
switch( variable name )
{
case 1 : statement
case 2 : statement
...
}
Hope it helps !!!
The syntax of switch statement is:
switch( variable name )
{
case 1 : statement
case 2 : statement
...
}
Hope it helps !!!
Similar questions