generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 194
Glasgow | ITP-SEP-25 | Alaa Tagi | Sprint 2 | Coursework/sprint 2 #886
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
Alaa-Tagi
wants to merge
17
commits into
CodeYourFuture:main
Choose a base branch
from
Alaa-Tagi:coursework/sprint-2
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.
+322
−52
Open
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e3d10bc
fix and predict anything that isn't working
Alaa-Tagi b1444af
fix and predict anything that isn't working
Alaa-Tagi fb7daba
fix and predict anything that isn't working
Alaa-Tagi 285095c
implement a function called contains
Alaa-Tagi a63ca91
implement a jest file that checks an object contains a particular pro…
Alaa-Tagi 80bd54c
implement a function called lookup
Alaa-Tagi 0404dc5
creat a jest file for lookup code
Alaa-Tagi 1b6db2a
fix the function
Alaa-Tagi 02f764a
create a jest file for querystring function
Alaa-Tagi a31ecb5
implement a function called tally
Alaa-Tagi 4d32436
create a jest file for tally code
Alaa-Tagi 3e0ac56
fix implementation and write tests to prove it's worked
Alaa-Tagi 046c190
implement functions and answer questions
Alaa-Tagi 35ac584
modified recipe function to let it work to any number of ingredients
Alaa-Tagi 9fc13aa
fix the code to let key and value be percent-encoded
Alaa-Tagi 99836eb
fix one line in the code and add two line to print the output
Alaa-Tagi 54171f9
fix the function and jest file
Alaa-Tagi 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| function contains() {} | ||
| function contains(input, propertyName) { | ||
| if (input && typeof input === 'object' && !Array.isArray(input)) { | ||
| return input.hasOwnProperty(propertyName); | ||
| } | ||
| return false; | ||
| }; | ||
|
|
||
| module.exports = contains; |
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,5 +1,9 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| function createLookup(pairs) { | ||
| const lookup = {}; | ||
| for (const [countryCode, currencyCode] of pairs) { | ||
| lookup[countryCode] = currencyCode; | ||
| } | ||
| return lookup; | ||
| } | ||
|
|
||
| module.exports = createLookup; |
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 |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| function tally() {} | ||
| function tally(items) { | ||
| if (!Array.isArray(items)) { | ||
| throw new TypeError('Input must be an array'); | ||
| } | ||
| const tallyResult = {}; | ||
cjyuan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (const item of items) { | ||
| if (tallyResult[item] === undefined) { | ||
| tallyResult[item] = 1; | ||
| } else { | ||
| tallyResult[item]++; | ||
| } | ||
| } | ||
| return tallyResult; | ||
| } | ||
|
|
||
| module.exports = tally; | ||
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 |
|---|---|---|
|
|
@@ -26,3 +26,22 @@ | |
|
|
||
| 3. Order the results to find out which word is the most common in the input | ||
| */ | ||
|
|
||
| function countWords(inputString) { | ||
|
|
||
| const cleanedString = inputString.replace(/[.,!?]/g, '').toLowerCase(); | ||
| const wordsArray = cleanedString.split(/\s+/); | ||
| const wordCount = {}; | ||
|
|
||
| for (const word of wordsArray) { | ||
| if (wordCount[word] === undefined) { | ||
| wordCount[word] = 1; | ||
| } else { | ||
| wordCount[word]++; | ||
| } | ||
| } | ||
|
|
||
| return wordCount; | ||
| } | ||
|
Comment on lines
+30
to
+45
Contributor
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. Change is optional. Here are some test cases you can try when you have time. |
||
|
|
||
| module.exports = countWords; | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.