-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
139 lines (115 loc) Β· 4.68 KB
/
index.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<title>Program Flow</title>
<style>
#verse {
font-style: italic;
font-size: 2em;
}
</style>
</head>
<body>
<h1>Program Flow</h1>
<p>Please load this file in VSCode and Chrome, and open the Console in Chrome Dev Tools.</p>
<p>Work through the challenges found inside the last script tag in this document,
until the verse below reads correctly and the Console reports all tests passing.</p>
<p id="verse"></p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.19.0/js/md5.js"></script>
<script>
// In CHALLENGEs 1-8 you will use conditional statements to assign values to the "result" variables below:
let result1, result2, result3, result4, result5, result6, result7, result8;
// To do this, translate each π§ pseudocode into a working conditional statement.
// β Do not change the values of any of the variables declared below.
// β Some pseudocodes have the conditions in the wrong order.
// β You can create new variables if you need to.
// β The first one is done for you:
// π CHALLENGE 1
const num1 = 7;
const num2 = 10;
// π§ pseudocode: if num1 bigger than num2, then result1 is string "come", otherwise "go"
if (num1 > num2) {
result1 = 'Stay';
} else {
result1 = 'Deep Fam';
}
// π CHALLENGE 2
const age1 = 18;
const age2 = 25;
const age3 = 34;
// π§ pseudocode: if any of the ages is under 18, then result2 is string "this", otherwise "that"
if (age1 < 18|| age2 < 18 || age3 < 18) {
result2 = 'this'
} else {
result2 = 'that'
}
// π CHALLENGE 3
const val1 = ' ';
const val2 = '';
const val3 = -1;
// π§ pseudocode: if all the vals are either truthy or the empty string, result3 is "Do", otherwise "Don't"
if ((val1 || val1 === '') && (val2 || val2 = '') && (val3 || val3 === '')) {
result3 = "Do it"
} else {
result3 = "Don't it"
}
// π CHALLENGE 4
const data1 = NaN;
const data2 = null;
const data3 = ' ';
// π§ pseudocode: if any of the pieces of data above is truthy, then result4 is "good", otherwise "bad"
// β¨ Your code here
// π CHALLENGE 5
const int1 = 32;
const int2 = 64;
const int3 = 128;
// π§ pseudocode: if any int greater than zero, then result5 is "harsh"; else if any int greater
// than 32, then "firm"; else if any int greater than 64, then "gentle"
// β¨ Your code here
// π CHALLENGE 6
const amount1 = 4;
const amount2 = 8;
const amount3 = 13;
// π§ pseudocode: if two out of the three amounts are divisible by 4, then result6 is "not", otherwise "so"
// β¨ Your code here
// π CHALLENGE 7
const friend1 = undefined;
const friend2 = 'undefined';
const friend3 = 'Peter';
// π§ pseudocode: if all friends are falsy, then result7 is "day"; else if no friends are falsy, then "twilight", else "night"
// β¨ Your code here
// π CHALLENGE 8
const monday = 0;
const tuesday = 1;
const wednesday = 2;
const thursday = 3;
const friday = 4;
const saturday = 5;
const sunday = 6;
const TODAY = wednesday;
// π§ pseudocode: if TODAY plus 657385 days is a
// - Monday, then result8 is "in"
// - Tuesday, then "at"
// - Wednesday, then "on"
// - Thursday, then "into"
// - Friday, then "from"
// - Saturday, then "within"
// - Sunday, then "beneath"
// β¨ Your code here
// Tests. Do not make any changes below this line!
const total = `${result3} ${result6} ${result1} ${result5} ${result8} ${result2} ${result4} ${result7}`;
verse.textContent = total;
const res = '[TEST] result';
const good = 'looks good β
';
const bad = 'is incorrect β';
console.log(md5(result1) === '34d1f91fb2e514b8576fab1a75a89a6b' ? `${res}1 ${good}` : `${res}1 ${bad}`);
console.log(md5(result2) === '21582c6c30be1217322cdb9aebaf4a59' ? `${res}2 ${good}` : `${res}2 ${bad}`);
console.log(md5(result3) === '0567953871b1bf589b797d9b178d5a94' ? `${res}3 ${good}` : `${res}3 ${bad}`);
console.log(md5(result4) === '755f85c2723bb39381c7379a604160d8' ? `${res}4 ${good}` : `${res}4 ${bad}`);
console.log(md5(result5) === 'a35b6ec571ce2ed20f7d3442987efb07' ? `${res}5 ${good}` : `${res}5 ${bad}`);
console.log(md5(result6) === 'd529e941509eb9e9b9cfaeae1fe7ca23' ? `${res}6 ${good}` : `${res}6 ${bad}`);
console.log(md5(result7) === '93a04b066fd81a1017825f2dcda313b2' ? `${res}7 ${good}` : `${res}7 ${bad}`);
console.log(md5(result8) === 'b971be0e2e7176b90d5501eca32a0226' ? `${res}8 ${good}` : `${res}8 ${bad}`);
</script>
</body>
</html>