Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Commit 42fb0ff

Browse files
committed
commit
more commit to exercise and mandatory
1 parent c3d4384 commit 42fb0ff

File tree

2 files changed

+53
-52
lines changed

2 files changed

+53
-52
lines changed

week-2/1-exercises/F-logical-operators/exercise.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ var cssLevel = 4;
1111

1212
// Finish the statement to check whether HTML, CSS knowledge are above 5
1313
// (hint: use the comparison operator from before)
14-
var htmlLevelAbove5 = 5;
15-
var cssLevelAbove5 = 5;
14+
var htmlLevelAbove5 = true;
15+
var cssLevelAbove5 = false;
1616

1717
// Finish the next two statement
1818
// Use the previous variables and logical operators
1919
// Do not "hardcode" the answers
20-
var cssAndHtmlAbove5;
21-
var cssOrHtmlAbove5;
20+
var cssAndHtmlAbove5 = false;
21+
var cssOrHtmlAbove5 = true;
2222

2323
/*
2424
DO NOT EDIT BELOW THIS LINE

week-2/2-mandatory/1-fix-functions.js

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,89 +2,90 @@
22
// Look at the tests and see how you can fix them.
33

44
function mood() {
5-
let isHappy = true;
5+
let isHappy = false;
66

7-
if (isHappy) {
8-
return "I am happy";
9-
} else {
10-
return "I am not happy";
11-
}
7+
if (isHappy) {
8+
return "I am happy";
9+
} else {
10+
return "I am not happy";
11+
}
1212
}
1313

1414
function greaterThan10() {
15-
let num = 10;
16-
let isBigEnough;
17-
18-
if (isBigEnough) {
19-
return "num is greater than or equal to 10";
20-
} else {
21-
return "num is not big enough";
22-
}
15+
let num = 10;
16+
let isBigEnough = true;
17+
18+
if (isBigEnough) {
19+
return "num is greater than or equal to 10";
20+
} else {
21+
return "num is not big enough";
22+
}
2323
}
2424

25-
function sortArray() {
26-
let letters = ["a", "n", "c", "e", "z", "f"];
27-
let sortedLetters;
25+
function sortArray(a, b) {
26+
let letters = ["a", "n", "c", "e", "z", "f"];
2827

29-
return sortedLetters;
28+
let sortedLetters = letters.sort(a, b);
29+
30+
return sortedLetters;
3031
}
3132

3233
function first5() {
33-
let numbers = [1, 2, 3, 4, 5, 6, 7, 8];
34-
let sliced;
34+
let numbers = [1, 2, 3, 4, 5, 6, 7, 8];
35+
let sliced = numbers.slice(0, 5);
3536

36-
return sliced;
37+
return sliced;
3738
}
3839

3940
function get3rdIndex(arr) {
40-
let index = 3;
41-
let element;
41+
let index = 3;
42+
let element = arr[index];
4243

43-
return element;
44+
return element;
4445
}
4546

4647
/* ======= TESTS - DO NOT MODIFY ===== */
4748

4849
function test(test_name, expr) {
49-
let status;
50-
if (expr) {
51-
status = "PASSED";
52-
} else {
53-
status = "FAILED";
54-
}
55-
56-
console.log(`${test_name}: ${status}`);
50+
let status;
51+
if (expr) {
52+
status = "PASSED";
53+
} else {
54+
status = "FAILED";
55+
}
56+
57+
console.log(`${test_name}: ${status}`);
5758
}
5859

5960
function arraysEqual(a, b) {
60-
if (a === b) return true;
61-
if (a == null || b == null) return false;
62-
if (a.length != b.length) return false;
61+
if (a === b) return true;
62+
if (a == null || b == null) return false;
63+
if (a.length != b.length) return false;
6364

64-
for (let i = 0; i < a.length; ++i) {
65-
if (a[i] !== b[i]) return false;
66-
}
65+
for (let i = 0; i < a.length; ++i) {
66+
if (a[i] !== b[i]) return false;
67+
}
6768

68-
return true;
69+
return true;
6970
}
7071

7172
test("mood function works", mood() === "I am not happy");
7273
test(
73-
"greaterThanTen function works",
74-
greaterThan10() === "num is greater than or equal to 10"
74+
"greaterThanTen function works",
75+
greaterThan10() === "num is greater than or equal to 10"
7576
);
7677
test(
77-
"sortArray function works",
78-
arraysEqual(sortArray(), ["a", "c", "e", "f", "n", "z"])
78+
"sortArray function works",
79+
arraysEqual(sortArray(), ["a", "c", "e", "f", "n", "z"])
7980
);
8081
test("first5 function works", arraysEqual(first5(), [1, 2, 3, 4, 5]));
8182

8283
test(
83-
"get3rdIndex function works - case 1",
84-
get3rdIndex(["fruit", "banana", "apple", "strawberry", "raspberry"]) ===
85-
"strawberry"
84+
"get3rdIndex function works - case 1",
85+
get3rdIndex(["fruit", "banana", "apple", "strawberry", "raspberry"]) ===
86+
"strawberry"
8687
);
8788
test(
88-
"get3rdIndex function works - case 2",
89-
get3rdIndex([11, 37, 62, 18, 19, 3, 30]) === 18
89+
"get3rdIndex function works - case 2",
90+
get3rdIndex([11, 37, 62, 18, 19, 3, 30]) === 18
9091
);

0 commit comments

Comments
 (0)