forked from Asabeneh/JavaScript-for-Everyone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
14-switch.js
47 lines (45 loc) · 1 KB
/
14-switch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Switch
var weather = "cloudy";
switch (weather) {
case "rainy":
console.log("It is raining. You need a rain coat.");
break;
case "cloudy":
console.log("It might be cold you need a jacket.");
break;
case "sunny":
console.log("Go out freely.");
break;
default:
console.log("It is not raining. No need for rain coat.");
break;
}
// Swithc More Examples
var dayUserInput = prompt('What day is it ?');
var day = dayUserInput.toLowerCase();
switch (day) {
case 'monday':
console.log('Today is Monday');
break;
case 'tuesday':
console.log('Today is Tuesday');
break;
case 'wednesday':
console.log('Today is Wednesday');
break;
case 'thursday':
console.log('Today is Thursday');
break;
case 'friday':
console.log('Today is Friday');
break;
case 'saturday':
console.log('Today is Saturday');
break;
case 'sunday':
console.log('Today is Sunday');
break;
default:
console.log('It is not a week day.');
break;
}