Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .test-summary/TEST_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

| Exercise | Passed | Failed | ESLint |
|----------------------|--------|--------|--------|
| ex1-giveCompliment | 3 | 4 | ✓ |
| ex2-dogYears | 4 | 3 | ✓ |
| ex3-tellFortune | 7 | 3 | ✓ |
| ex1-giveCompliment | 7 | - | ✓ |
| ex2-dogYears | 7 | - | ✓ |
| ex3-tellFortune | 10 | - | ✓ |
| ex4-shoppingCart | - | - | ✓ |
| ex5-shoppingCartPure | - | - | ✓ |
| ex6-totalCost | - | - | ✓ |
Expand Down
14 changes: 5 additions & 9 deletions 1-JavaScript/Week2/assignment/ex1-giveCompliment.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
/* -----------------------------------------------------------------------------
Full description at: https://github.com/HackYourFuture/Assignments/tree/main/1-JavaScript/Week3#exercise-1-you-are-amazing

1. Complete the function named `giveCompliment`as follows:

export function giveCompliment(name) {
export function giveCompliment(name) {
const compliments = [
"great",
"awesome",
Expand All @@ -16,22 +11,23 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/1-J
"marvelous",
"exceptional"
];

const i = Math.floor(Math.random() * compliments.length);
return `You are ${compliments[i]}, ${name}!`;
}

function main() {
const myName = "HackYourFuture";
const myName = "Rim";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

console.log(giveCompliment(myName));
console.log(giveCompliment(myName));
console.log(giveCompliment(myName));

const yourName = "Amsterdam";
const yourName = "Hadid";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

console.log(giveCompliment(yourName));
console.log(giveCompliment(yourName));
console.log(giveCompliment(yourName));
}

if (process.env.NODE_ENV !== "test") {
main();
}
}
18 changes: 6 additions & 12 deletions 1-JavaScript/Week2/assignment/ex2-dogYears.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
export function calculateDogAge(humanYears) {
return humanYears * 7;
const dogYears = humanYears * 7;
return `Your doggie is ${dogYears} years old in dog years!`;
Comment on lines +2 to +3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

function main() {
const myAge = 25;
console.log(
`If you are ${myAge} years old, that's ${calculateDogAge(myAge)} in dog years!`
);

const yourAge = 40;
console.log(
`If you are ${yourAge} years old, that's ${calculateDogAge(yourAge)} in dog years!`
);
console.log(calculateDogAge(1));
console.log(calculateDogAge(2));
console.log(calculateDogAge(3));
Comment on lines +7 to +9

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

if (process.env.NODE_ENV !== "test") {
if (process.env.NODE_ENV !== 'test') {
main();
}

59 changes: 17 additions & 42 deletions 1-JavaScript/Week2/test-reports/ex1-giveCompliment.report.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,23 @@
*** Unit Test Error Report ***

Command failed: npx jest C:/Users/Rimha/Assignments-Cohort54/.dist/1-JavaScript/Week2/unit-tests/ex1-giveCompliment.test.js --colors --noStackTrace --json
FAIL .dist/1-JavaScript/Week2/unit-tests/ex1-giveCompliment.test.js
PASS .dist/1-JavaScript/Week2/unit-tests/ex1-giveCompliment.test.js
js-wk2-ex1-giveCompliment
❌ should exist and be executable (4 ms)
✅ should have all TODO comments removed (1 ms)
✅ `giveCompliment` should not contain unneeded console.log calls (1 ms)
❌ should take a single parameter (1 ms)
✅ should include a `compliments` array inside its function body (1 ms)
❌ the `compliments` array should be initialized with 10 strings (1 ms)
❌ should give a random compliment: You are `compliment`, `name`!

● js-wk2-ex1-giveCompliment › should exist and be executable

expect(received).toBeDefined()

Received: undefined

● js-wk2-ex1-giveCompliment › should take a single parameter

expect(received).toHaveLength(expected)

Matcher error: received value must have a length property whose value must be a number

Received has value: undefined

● js-wk2-ex1-giveCompliment › the `compliments` array should be initialized with 10 strings

expect(received).toHaveLength(expected)

Expected length: 10
Received length: 0
Received array: []

● js-wk2-ex1-giveCompliment › should give a random compliment: You are `compliment`, `name`!

expect(received).toBeDefined()

Received: undefined

Test Suites: 1 failed, 1 total
Tests: 4 failed, 3 passed, 7 total
✅ should exist and be executable (1 ms)
✅ should have all TODO comments removed
✅ `giveCompliment` should not contain unneeded console.log calls
✅ should take a single parameter (1 ms)
✅ should include a `compliments` array inside its function body
✅ the `compliments` array should be initialized with 10 strings
✅ should give a random compliment: You are `compliment`, `name`!

Test Suites: 1 passed, 1 total
Tests: 7 passed, 7 total
Snapshots: 0 total
Time: 1.293 s
Time: 0.715 s, estimated 1 s
Ran all test suites matching /C:\\Users\\Rimha\\Assignments-Cohort54\\.dist\\1-JavaScript\\Week2\\unit-tests\\ex1-giveCompliment.test.js/i.
No linting errors detected.
No spelling errors detected.


*** Spell Checker Report ***

1-JavaScript/Week2/assignment/ex1-giveCompliment.js:25:21 - Unknown word (Hadid)
40 changes: 9 additions & 31 deletions 1-JavaScript/Week2/test-reports/ex2-dogYears.report.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
*** Unit Test Error Report ***

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

● js-wk2-ex2-dogYears › should give 7 dog years for 1 human year

expect(received).toBe(expected) // Object.is equality

Expected: "Your doggie is 7 years old in dog years!"
Received: 7

● js-wk2-ex2-dogYears › should give 14 dog years for 2 human years

expect(received).toBe(expected) // Object.is equality

Expected: "Your doggie is 14 years old in dog years!"
Received: 14

● js-wk2-ex2-dogYears › give 21 dog years for 3 human years

expect(received).toBe(expected) // Object.is equality

Expected: "Your doggie is 21 years old in dog years!"
Received: 21

Test Suites: 1 failed, 1 total
Tests: 3 failed, 4 passed, 7 total
Test Suites: 1 passed, 1 total
Tests: 7 passed, 7 total
Snapshots: 0 total
Time: 1.221 s
Time: 0.733 s, estimated 1 s
Ran all test suites matching /C:\\Users\\Rimha\\Assignments-Cohort54\\.dist\\1-JavaScript\\Week2\\unit-tests\\ex2-dogYears.test.js/i.
No linting errors detected.
No spelling errors detected.