Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jim3 w2 java script #4

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .test-summary/TEST_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Test Summary

**Mentors**: For more information on how to review homework assignments, please refer to the [Review Guide](https://github.com/HackYourFuture/mentors/blob/main/assignment-support/review-guide.md).

### 1-JavaScript - Week2

| Exercise | Passed | Failed | ESLint |
|--------------------|--------|--------|--------|
| ex1-giveCompliment | 6 | 1 | ✕ |
29 changes: 24 additions & 5 deletions 1-JavaScript/Week2/assignment/ex1-giveCompliment.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,39 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/1-J
Use `console.log` each time to display the return value of the
`giveCompliment` function to the console.
-----------------------------------------------------------------------------*/
export function giveCompliment(/* TODO parameter(s) go here */) {
// TODO complete this function
export function giveCompliment(name) {
//Array of compliments names
const compliments = [
'amazing',
'awesome',
'brilliant',
'clever',
'wonderful',
'excellent',
'fantastic',
'funny',
'smart',
];
// Randomly select a compliment
const randomIndex = Math.floor(Math.random() * compliments.length);
const compliment = compliments[randomIndex];

// Return the compliment string
return `You are ${compliment}, ${name}!`;
}

function main() {
// TODO substitute your own name for "HackYourFuture"
const myName = 'HackYourFuture';
const myName = 'Hossein';

// Call the function three times with myName
console.log(giveCompliment(myName));
console.log(giveCompliment(myName));
console.log(giveCompliment(myName));

const yourName = 'Amsterdam';
// Another example with a different name
const yourName = 'Kelisa';

// Call the function three times with yourName
console.log(giveCompliment(yourName));
console.log(giveCompliment(yourName));
console.log(giveCompliment(yourName));
Expand Down
33 changes: 33 additions & 0 deletions 1-JavaScript/Week2/test-reports/ex1-giveCompliment.report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
*** Unit Test Error Report ***

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

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

expect(received).toHaveLength(expected)

Expected length: 10
Received length: 9
Received array: ["amazing", "awesome", "brilliant", "clever", "wonderful", "excellent", "fantastic", "funny", "smart"]

Test Suites: 1 failed, 1 total
Tests: 1 failed, 6 passed, 7 total
Snapshots: 0 total
Time: 0.365 s
Ran all test suites matching /\/Volumes\/Crucial2TB\/xdev\/hackyourfuture\/Assignments-cohort51\/.dist\/1-JavaScript\/Week2\/unit-tests\/ex1-giveCompliment.test.js/i.
No linting errors detected.


*** Spell Checker Report ***

1-JavaScript/Week2/assignment/ex1-giveCompliment.js:42:19 - Unknown word (Hossein)
1-JavaScript/Week2/assignment/ex1-giveCompliment.js:50:21 - Unknown word (Kelisa)