Skip to content

Commit b137d8f

Browse files
committed
Remove conditionals3 test from JavaScript module
1 parent 521d749 commit b137d8f

5 files changed

Lines changed: 24 additions & 168 deletions

File tree

‎javascript/building-blocks/tasks/conditionals/conditionals3-download.html‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8"/>
5-
<title>Conditionals: Task 3</title>
5+
<title>Conditionals: Task 4</title>
66
<style>
77
p {
88
color: purple;
@@ -26,15 +26,13 @@
2626

2727
</body>
2828
<script>
29-
let response;
30-
let score = 75;
31-
let machineActive = false;
29+
let machineActive = true;
30+
let pwd = 'cheese';
3231

33-
if(machineActive) {
34-
// Add your code here
35-
} else {
36-
response = 'The machine is turned off. Turn it on to process your score.';
37-
}
32+
let machineResult;
33+
let pwdResult;
34+
35+
// Add your code here
3836

3937
// Don't edit the code below here!
4038

@@ -43,8 +41,8 @@
4341
let para1 = document.createElement('p');
4442
let para2 = document.createElement('p');
4543

46-
para1.textContent = `Your score is ${ score }.`;
47-
para2.textContent = response;
44+
para1.textContent = machineResult;
45+
para2.textContent = pwdResult;
4846

4947
section.appendChild(para1);
5048
section.appendChild(para2);

‎javascript/building-blocks/tasks/conditionals/conditionals3.html‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>Conditionals: Task 3</title>
5+
<title>Conditionals: Task 4</title>
66
<link rel="stylesheet" href="../styles.css" />
77
<style>
88
* {
@@ -25,24 +25,22 @@
2525

2626
<textarea class="playable playable-js" style="height: 220px;">
2727

28-
let response;
29-
let score = 75;
30-
let machineActive = false;
28+
let machineActive = true;
29+
let pwd = 'cheese';
3130

32-
if(machineActive) {
33-
// Add your code here
34-
} else {
35-
response = 'The machine is turned off. Turn it on to process your score.';
36-
}
31+
let machineResult;
32+
let pwdResult;
33+
34+
// Add your code here
3735

3836
// Don't edit the code below here!
3937

4038
section.innerHTML = ' ';
4139
let para1 = document.createElement('p');
4240
let para2 = document.createElement('p');
4341

44-
para1.textContent = `Your score is ${ score }.`;
45-
para2.textContent = response;
42+
para1.textContent = machineResult;
43+
para2.textContent = pwdResult;
4644

4745
section.appendChild(para1);
4846
section.appendChild(para2);

‎javascript/building-blocks/tasks/conditionals/conditionals4-download.html‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎javascript/building-blocks/tasks/conditionals/conditionals4.html‎

Lines changed: 0 additions & 55 deletions
This file was deleted.

‎javascript/building-blocks/tasks/conditionals/marking.md‎

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ You need to create one `if ... else` structure that checks whether the machine i
3535

3636
Inside the `if` part, you need to nest an `if ... else if` structure that puts appropriate messages into the `response` variable depending on different scores. The conditional operator tests should look like this:
3737

38-
* `score < 0 || score > 100` - "This is not possible, an error has occurred." This could also be done just by an `else` clause, as the scores between 0 and 100 are all covered by the other clauses. But it's nice to be exact.
39-
* `score >= 0 && score < 20` - "That was a terrible score — total fail!"
40-
* `score >= 20 && score < 40` - "You know some things, but it\'s a pretty bad score. Needs improvement."
41-
* `score >= 40 && score < 70` — "You did a passable job, not bad!"
42-
* `score >= 70 && score < 90` — "That\'s a great score, you really know your stuff."
43-
* `score >= 90 && score <= 100` — "What an amazing score! Did you cheat? Are you for real?"
38+
- `score < 0 || score > 100` - "This is not possible, an error has occurred." This could also be done just by an `else` clause, as the scores between 0 and 100 are all covered by the other clauses. But it's nice to be exact.
39+
- `score >= 0 && score < 20` - "That was a terrible score — total fail!"
40+
- `score >= 20 && score < 40` - "You know some things, but it\'s a pretty bad score. Needs improvement."
41+
- `score >= 40 && score < 70` — "You did a passable job, not bad!"
42+
- `score >= 70 && score < 90` — "That\'s a great score, you really know your stuff."
43+
- `score >= 90 && score <= 100` — "What an amazing score! Did you cheat? Are you for real?"
4444

4545
The finished code should look something like this:
4646

@@ -70,40 +70,6 @@ if (machineActive) {
7070

7171
## Task 3
7272

73-
In this task we want you to take the code you wrote for the previous example, and convert it so that the inner structure uses a `switch` statement.
74-
75-
Use the switch `default` option for the "not possible" option.
76-
77-
The full `if ... else` block including added `switch` statement should look like this:
78-
79-
```
80-
if (machineActive) {
81-
switch (true) {
82-
case (score >= 0 && score < 20):
83-
response = 'That was a terrible score — total fail!';
84-
break;
85-
case (score >= 20 && score < 40):
86-
response = 'You know some things, but it\'s a pretty bad score. Needs improvement.';
87-
break;
88-
case (score >= 40 && score < 70):
89-
response = 'You did a passable job, not bad!';
90-
break;
91-
case (score >= 70 && score < 90):
92-
response = 'That\'s a great score, you really know your stuff.';
93-
break;
94-
case (score >= 90 && score <= 100):
95-
response = 'What an amazing score! Did you cheat? Are you for real?';
96-
break;
97-
default:
98-
response = 'This is not possible, an error has occurred.';
99-
}
100-
} else {
101-
response = 'The machine is turned off. Turn it on to process your score.';
102-
}
103-
```
104-
105-
## Task 4
106-
10773
For the final task we have to offer in this set, we need you to first write an `if ... else` statement that checks whether `machineActive` is `true`. If so, set `machineResult` to a string telling the user they can successfully log in. If not, set it to a message telling them they need to activate the machine before they can log in.
10874

10975
Inside the `if` part of the structure, you need to write a ternary operator that checks whether `pwd` is equal to `cheese`. If so, it assigns a string saying that the login was successful; if not assign a string saying the log in failed. The result should be assigned to a variable called `pwdResult`.

0 commit comments

Comments
 (0)