This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy path1-fix-functions.js
More file actions
61 lines (45 loc) · 1.37 KB
/
1-fix-functions.js
File metadata and controls
61 lines (45 loc) · 1.37 KB
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
/* Fix Functions
Aim: to understand the change code inside functions
See the below functions. They are syntactically correct but are not outputting the right results.
Run the tests and see how you can fix them.
NOTE:Only make edits inside the function
*/
function getMood(isHappy) {
let isHappy = true;
if (isHappy) {
return "I am happy";
} else {
return "I am not happy";
}
}
function greaterThan10(num) {
let isBigEnough = Number > 10;
if (isBigEnough) {
return "num is greater than 10";
} else {
return "num is not big enough";
}
}
/* ======= TESTS - DO NOT MODIFY ===== */
describe("getMood", () => {
test("getMood function works for true", () => {
expect(getMood(true)).toEqual("I am happy");
});
test("getMood function works for false", () => {
expect(getMood(false)).toEqual("I am not happy");
});
});
describe("greaterThanTen", () => {
test("works for value greater than 10", () => {
expect(greaterThan10(11)).toEqual("num is greater than 10");
});
test("works for value much greater than 10", () => {
expect(greaterThan10(96)).toEqual("num is greater than 10");
});
test("works for value less than 10", () => {
expect(greaterThan10(9)).toEqual("num is not big enough");
});
test("works for value equal to 10", () => {
expect(greaterThan10(10)).toEqual("num is not big enough");
});
});