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 265
London10 - Khalil Alhaydr - JavaScrpit-Core-2-Coursework-Week1 #220
Open
Khlil1313
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
Khlil1313:main
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 all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
968aeb9
update exercises Q1
Khlil1313 e9cd528
update QA exercise 1
Khlil1313 93cc64c
update QA exercise 3
Khlil1313 d77afcb
update QB exercise1
Khlil1313 4a80fe4
update QB exercise2
Khlil1313 98bd0c2
update QC exercise1
Khlil1313 48ae9be
update QD exercise1
Khlil1313 9beadeb
update madatory recipe
Khlil1313 afabea5
add testsLine
Khlil1313 b0a83e3
removed test line
Khlil1313 83ca50e
creat a lookup function
Khlil1313 8cbec6a
add the orderburger and orderFalafel properties
Khlil1313 64976b6
finished the npm tests
Khlil1313 a74a6ad
finised the tests
Khlil1313 084afd6
update peru object
Khlil1313 3449c2b
updat the creatShoppingList
Khlil1313 e1938d9
finish the shoppingList function
Khlil1313 1ffc750
update the function
Khlil1313 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
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
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
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 |
|---|---|---|
|
|
@@ -22,4 +22,22 @@ | |
| You should write and log at least 5 recipes | ||
| */ | ||
|
|
||
| // write code here | ||
| // write code here | ||
|
|
||
| let favRecipe1 = { | ||
| name: "salads", | ||
| servings: "services: " + 2, | ||
| ingredients: ["tomato", "cucamber", "lemon", "avocado", "sweetcorn", "eggs"] | ||
| } | ||
| function ingredientPrinting(favRecipe1) { | ||
| console.log("ingredients: ") | ||
| for ( let i = 0; i < favRecipe1.ingredients.length; i++) { | ||
| console.log(favRecipe1.ingredients[i]); | ||
| } | ||
| } | ||
|
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. Comment: Nicely written function |
||
|
|
||
|
|
||
| console.log(favRecipe1.name); | ||
| console.log(favRecipe1.servings); | ||
| ingredientPrinting(favRecipe1); | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -18,8 +18,18 @@ const COUNTRY_CURRENCY_CODES = [ | |
| ]; | ||
|
|
||
| function createLookup(countryCurrencyCodes) { | ||
| // write code here | ||
| let key; | ||
| let value; | ||
| let countryCurrencyObject = {}; | ||
| for (let i = 0; i < countryCurrencyCodes.length; i++) { | ||
| key = countryCurrencyCodes[i][0]; | ||
| value = countryCurrencyCodes[i][1]; | ||
| countryCurrencyObject[key] = value; | ||
| } | ||
| return countryCurrencyObject | ||
| } | ||
|
|
||
| console.log(createLookup(COUNTRY_CURRENCY_CODES)) | ||
|
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. Comment: Nice! Consider: You could consider to check a .forEach const lookup = createLookup(COUNTRY_CURRENCY_CODES); |
||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
| - To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js` | ||
|
|
@@ -34,4 +44,5 @@ test("creates country currency code lookup", () => { | |
| NG: "NGN", | ||
| MX: "MXN", | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
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
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 |
|---|---|---|
|
|
@@ -10,7 +10,9 @@ | |
| trainee has completed. | ||
| */ | ||
|
|
||
| function convertScoreToGrade() { | ||
| const { TestScheduler } = require("jest"); | ||
|
|
||
| function convertScoreToGrade(score) { | ||
| let grade = null; | ||
|
|
||
| if (score >= 80) { | ||
|
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. Comment: Well done! |
||
|
|
@@ -55,6 +57,13 @@ function formatCourseworkResult(trainee) { | |
| score: 63 | ||
| } | ||
| */ | ||
| test("Xin's coursework was marked as grade C", () => { | ||
| let trainee = { | ||
| name: "Xin", | ||
| score: 63, | ||
| } | ||
| expect(formatCourseworkResult(trainee)).toEqual("Xin's coursework was marked as grade C.") | ||
| }); | ||
|
|
||
| /* | ||
| Write a test that checks the output of formatCourseworkResult when passed the following trainee: | ||
|
|
@@ -63,6 +72,13 @@ function formatCourseworkResult(trainee) { | |
| score: 78 | ||
| } | ||
| */ | ||
| test("Mona's coursework was marked as grade B", () => { | ||
| let trainee = { | ||
| name: "Mona", | ||
| score: 78, | ||
| } | ||
| expect(formatCourseworkResult(trainee)).toEqual("Mona's coursework was marked as grade B.") | ||
| }); | ||
|
|
||
| /* | ||
| Write a test that checks the output of formatCourseworkResult when passed the following trainee: | ||
|
|
@@ -73,6 +89,15 @@ function formatCourseworkResult(trainee) { | |
| subjects: ["JavaScript", "React", "CSS"] | ||
| } | ||
| */ | ||
| test("Ali's coursework was marked as grade E", () => { | ||
| let trainee = { | ||
| name: "Ali", | ||
| score: 49, | ||
| age: 33, | ||
| subjects: ["JavaScript", "React", "CSS"] | ||
| } | ||
| expect(formatCourseworkResult(trainee)).toEqual("Ali's coursework was marked as grade E.") | ||
| }); | ||
|
|
||
| /* | ||
| Write a test that checks the output of formatCourseworkResult when passed the following trainee: | ||
|
|
@@ -81,6 +106,13 @@ function formatCourseworkResult(trainee) { | |
| age: 29 | ||
| } | ||
| */ | ||
| test("no trainee name is equal to Error: No trainee name!", () => { | ||
| let trainee = { | ||
| score: 90, | ||
| age: 29, | ||
| } | ||
| expect(formatCourseworkResult(trainee)).toEqual("Error: No trainee name!") | ||
| }); | ||
|
|
||
| /* | ||
| Write a test that checks the output of formatCourseworkResult when passed the following trainee: | ||
|
|
@@ -89,3 +121,12 @@ function formatCourseworkResult(trainee) { | |
| subjects: ["HTML", "CSS", "Databases"] | ||
| } | ||
| */ | ||
| test("no trainee score is equal to Error: Coursework percent is not a number!", () => { | ||
| let trainee = { | ||
| name: "Aman", | ||
| subjects: ["HTML", "CSS", "Databasese"], | ||
|
|
||
| } | ||
| expect(formatCourseworkResult(trainee)).toEqual("Error: Coursework percent is not a number!") | ||
| }); | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -25,8 +25,8 @@ | |
|
|
||
| function countWords(string) { | ||
| const wordCount = {}; | ||
|
|
||
| // write code here | ||
|
|
||
|
|
||
| return wordCount; | ||
| } | ||
|
|
||
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.
you could possibly write like:
function isPassed (attendance, examScore) {
return attendance >= 90 && examScore > 60
}
'return' returns boolean!