forked from HackYourFuture/Assignments
-
Notifications
You must be signed in to change notification settings - Fork 7
Hadid w2 javascript #24
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
Open
Hadidreem17
wants to merge
7
commits into
HackYourAssignment:main
Choose a base branch
from
Hadidreem17:hadid-w2-javascript
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dce57a7
submit week2 assignment
Hadidreem17 85288a5
test (w2) : ran ex7 mindPrivacy locally
Hadidreem17 84f2263
Week2: fix solution for ex3-tellFortune
Hadidreem17 2223d93
Fix Week2 ex4-shoppingCart based on feedback
Hadidreem17 1688ff7
update ex1 and ex2
Hadidreem17 90daffc
add solve ex1 and ex2
Hadidreem17 8b16f37
Solved ex1-giveCompliment and ex2-dogYears
Hadidreem17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
|
|
@@ -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"; | ||
| console.log(giveCompliment(myName)); | ||
| console.log(giveCompliment(myName)); | ||
| console.log(giveCompliment(myName)); | ||
|
|
||
| const yourName = "Amsterdam"; | ||
| const yourName = "Hadid"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
59
1-JavaScript/Week2/test-reports/ex1-giveCompliment.report.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍