forked from bethrobson/Head-First-JavaScript-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoffee.html
More file actions
36 lines (31 loc) · 693 Bytes
/
coffee.html
File metadata and controls
36 lines (31 loc) · 693 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
32
33
34
35
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Coffee Constructor</title>
<script>
function Coffee(roast, ounces) {
this.roast = roast;
this.ounces = ounces;
this.getSize = function() {
if (this.ounces === 8) {
return "small";
} else if (this.ounces === 12) {
return "medium";
} else if (this.ounces === 16) {
return "large";
}
};
this.toString = function() {
return "You've ordered a " + this.getSize() + " " + this.roast + " coffee.";
};
}
var coffee = new Coffee("House Blend", 12);
console.log(coffee.toString());
var darkRoast = new Coffee("Dark Roast", 16);
console.log(darkRoast.toString());
</script>
</head>
<body>
</body>
</html>