-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorial18 Switch.html
More file actions
31 lines (28 loc) · 921 Bytes
/
Tutorial18 Switch.html
File metadata and controls
31 lines (28 loc) · 921 Bytes
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
<!doctype html>
<html>
<head>
<title>
Tutorial 18 JavaScript -- Switch
</title>
</head>
<body>
<script type="text/javascript"> // Tag to include JavaScript in HTML.
var color = "red";
switch(color){
case "red":
document.write("Color is Red");
break;
case "blue":
document.write("color is blue");
break;
default:
document.write("no color matched");
}
/* Take aways: When we are testing a range of different possible outcomes of the same conditional statement.
its always better to use switch.
Default is last case to be executed when none case becomes true.
Dafault will not have case keyword against it.
*/
</script>
</body>
</html>