forked from bethrobson/Head-First-JavaScript-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvaccine.html
More file actions
45 lines (39 loc) · 669 Bytes
/
vaccine.html
File metadata and controls
45 lines (39 loc) · 669 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
36
37
38
39
40
41
42
43
44
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>First class functions exercise</title>
<script>
//
// for testing:
//
function administer(name, vaccine, time) {
var dosage = 10;
console.log("Time to give " + name + " a vaccine: " + time);
vaccine(dosage);
}
function inject(dosage) {
console.log("Injecting " + dosage + "ml");
}
var patient = "Fido";
var time = "5 minutes";
// no longer needed...
/*
function vaccine(dosage) {
if (dosage > 0) {
inject(dosage);
}
}
*/
//
// solution:
//
administer(patient, function(dosage) {
if (dosage > 0) {
inject(dosage);
}
}, time);
</script>
</head>
<body> </body>
</html>