Skip to content

Commit 90daffc

Browse files
committed
add solve ex1 and ex2
1 parent 1688ff7 commit 90daffc

File tree

3 files changed

+16
-38
lines changed

3 files changed

+16
-38
lines changed

.test-summary/TEST_SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
| Exercise | Passed | Failed | ESLint |
88
|----------------------|--------|--------|--------|
99
| ex1-giveCompliment | 3 | 4 ||
10-
| ex2-dogYears | 4 | 3 ||
11-
| ex3-tellFortune | 7 | 3 ||
10+
| ex2-dogYears | 7 | - ||
11+
| ex3-tellFortune | 10 | - ||
1212
| ex4-shoppingCart | - | - ||
1313
| ex5-shoppingCartPure | - | - ||
1414
| ex6-totalCost | - | - ||
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export function calculateDogAge(humanYears) {
22
const dogYears = humanYears * 7;
3-
return `If you are ${humanYears} years old, that's ${dogYears} in dog years!`;
3+
return `Your doggie is ${dogYears} years old in dog years!`;
44
}
55

66
function main() {
7-
console.log(calculateDogAge(25));
8-
console.log(calculateDogAge(40));
7+
console.log(calculateDogAge(1));
8+
console.log(calculateDogAge(2));
9+
console.log(calculateDogAge(3));
910
}
1011

11-
if (process.env.NODE_ENV !== "test") {
12+
if (process.env.NODE_ENV !== 'test') {
1213
main();
1314
}
14-
Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
11
*** Unit Test Error Report ***
22

3-
Command failed: npx jest C:/Users/Rimha/Assignments-Cohort54/.dist/1-JavaScript/Week2/unit-tests/ex2-dogYears.test.js --colors --noStackTrace --json
4-
FAIL .dist/1-JavaScript/Week2/unit-tests/ex2-dogYears.test.js
3+
PASS .dist/1-JavaScript/Week2/unit-tests/ex2-dogYears.test.js
54
js-wk2-ex2-dogYears
6-
✅ should exist and be executable (3 ms)
5+
✅ should exist and be executable (1 ms)
76
✅ should have all TODO comments removed
8-
✅ `calculateDogAge` should not contain unneeded console.log calls (2 ms)
7+
✅ `calculateDogAge` should not contain unneeded console.log calls
98
✅ should take a single parameter (1 ms)
10-
should give 7 dog years for 1 human year (3 ms)
11-
should give 14 dog years for 2 human years
12-
give 21 dog years for 3 human years (1 ms)
9+
should give 7 dog years for 1 human year
10+
should give 14 dog years for 2 human years (1 ms)
11+
give 21 dog years for 3 human years
1312

14-
● js-wk2-ex2-dogYears › should give 7 dog years for 1 human year
15-
16-
expect(received).toBe(expected) // Object.is equality
17-
18-
Expected: "Your doggie is 7 years old in dog years!"
19-
Received: 7
20-
21-
● js-wk2-ex2-dogYears › should give 14 dog years for 2 human years
22-
23-
expect(received).toBe(expected) // Object.is equality
24-
25-
Expected: "Your doggie is 14 years old in dog years!"
26-
Received: 14
27-
28-
● js-wk2-ex2-dogYears › give 21 dog years for 3 human years
29-
30-
expect(received).toBe(expected) // Object.is equality
31-
32-
Expected: "Your doggie is 21 years old in dog years!"
33-
Received: 21
34-
35-
Test Suites: 1 failed, 1 total
36-
Tests: 3 failed, 4 passed, 7 total
13+
Test Suites: 1 passed, 1 total
14+
Tests: 7 passed, 7 total
3715
Snapshots: 0 total
38-
Time: 1.221 s
16+
Time: 0.733 s, estimated 1 s
3917
Ran all test suites matching /C:\\Users\\Rimha\\Assignments-Cohort54\\.dist\\1-JavaScript\\Week2\\unit-tests\\ex2-dogYears.test.js/i.
4018
No linting errors detected.
4119
No spelling errors detected.

0 commit comments

Comments
 (0)