-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJs scope project.html
59 lines (50 loc) · 1.37 KB
/
Js scope project.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Js scope project</title>
</head>
<body>
<script>
const name1 = "jorn";
const name2 = "Sally";
const readEvent = () => {
const random = Math.floor(Math.random() * 3);
console.log(random);
if (random === 0) {
return "Marathon";
} else if (random === 1) {
return "Triathon";
} else if (random === 2) {
return "pentathon";
}
};
const getTraining = (event) => {
let days;
if (event === "Marathon") {
days = 50;
} else if (event === "Triathon") {
days = 80;
} else if (event === "pentathon") {
days = 22;
}
return days;
};
const logEvent = (name, event) => {
console.log(`${name}'s event is: ${event}`);
};
const logTime = (name, days) => {
console.log(`${name}'s time to train is ${days} days`);
};
const event = readEvent();
const days = getTraining(event);
logEvent(name1, event);
logTime(name1z, days);
const event2 = readEvent();
const days2 = getTraining(event2);
logEvent(name2, event2);
logTime(name2, days2);
</script>
</body>
</html>