+ 1

how should I use the switch and what is it function

18th Sep 2016, 9:14 PM
Richmond Kwarteng
Richmond Kwarteng - avatar
2 Answers
+ 1
if u want to check three more condition use it swtich statement eg u having values Sunday ,Monday,Tuesday this values are stored in string when use swtich statement if u retrieve the values Sunday mean string Days ="Sunday"; switch(Days) { case "Sunday" : console. writeline("Holiday"); break; case "Monday": console.writeline(" working day'); break; ............etc this is use of switch statement
20th Sep 2016, 4:07 PM
Mohamed Azarudeen
Mohamed Azarudeen - avatar
0
The switch is very similar to the if/else. Switch to me looks prettier, but in the long runs messier. The if/else uses mathematical operators like < > <=... While the switch only uses == by default.
19th Sep 2016, 5:51 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar