+ 1
How can i make this functional
JavaScript with switch case https://code.sololearn.com/WZTObAba3hw2/?ref=app
2 Answers
+ 2
var val= prompt("enter Yes/No"); //taking user input by prompt
switch(val)
{
case 'Yes':
console.log("ok then")
break;
case 'No':
console.log("fine")
break;
default :
console.log("no")
}
+ 1
The condition for the cases must be of a type that val can be compared to, e.g. a string or a number.
But currently Yes and No are not defined