0
Java Script Switch
Please tell me how to write this code in switch format <script> var firstnum=prompt("Enter the first number"); var secondnum=prompt("Enter the second number"); if(firstnum>secondnum) { document.write("oh "+ firstnum + " is big then "+ secondnum ); } else if(secondnum>firstnum) { document.write( "oh "+ secondnum + " is big then "+ firstnum); } else if (firstnum==secondnum) { document.write( "Sorry! Your Both Number are equal Try Another"); } else { document.write("Error Please enter a valid number"); } </script>
2 Respostas
+ 2
var x = first - second;
switch (Math.sign(x)) {
case 1:
...
break;
case - 1:
...
break;
case 0:
...
}
+ 1
I think if else statement is best option here