forked from bethrobson/Head-First-JavaScript-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprequal.html
More file actions
86 lines (75 loc) · 1.51 KB
/
prequal.html
File metadata and controls
86 lines (75 loc) · 1.51 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html lang="en">
<head>
<title>Prequalifcation</title>
<meta charset="utf-8">
<script>
var chevy = {
make: "Chevy",
model: "Bel Air",
year: 1957,
color: "red",
passengers: 2,
convertible: false,
mileage: 1021
};
var fiat = {
make: "Fiat",
model: "500",
year: 1957,
color: "Medium Blue",
passengers: 2,
convertible: false,
mileage: 88000
};
var cadi = {
make: "GM",
model: "Cadillac",
year: 1955,
color: "tan",
passengers: 5,
convertible: false,
mileage: 12892
};
var taxi = {
make: "WebVille Motors",
model: "Taxi",
year: 1955,
color: "yellow",
passengers: 4,
convertible: false,
mileage: 281341
};
function prequal(car) {
if (car.mileage > 10000) {
return false;
} else if (car.year > 1960) {
return false;
}
return true;
}
var worthALook = prequal(taxi);
if (worthALook) {
console.log("You gotta check out this " + taxi.make + " " + taxi.model);
} else {
console.log("You should really pass on the " + taxi.make + " " + taxi.model);
}
//
// add a function to make it easier to generate the console output!
//
function isWorthALook(didQualify, car) {
if (didQualify) {
console.log("You gotta check out this " + car.make + " " + car.model);
} else {
console.log("You should really pass on the " + car.make + " " + car.model);
}
}
isWorthALook(prequal(taxi), taxi);
isWorthALook(prequal(cadi), cadi);
isWorthALook(prequal(chevy), chevy);
isWorthALook(prequal(fiat), fiat);
</script>
</head>
<body>
</body>
</html>