Computer Science, asked by mithu25, 1 year ago

write the syntax of switch statement.


SagnikPradhan: In which Language...?
mithu25: english
mithu25: java programming

Answers

Answered by nitin178
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 +'.');



}

Answered by AritraK
6
Dear friend,

The syntax of switch statement is:

switch( variable name )
{
case 1 : statement
case 2 : statement
...
}

Hope it helps !!!
Similar questions