Glasgow | ITP-SEP-25 | Alaa Tagi | Sprint 2 | Coursework/sprint 2#886
Closed
Alaa-Tagi wants to merge 17 commits intoCodeYourFuture:mainfrom
Closed
Glasgow | ITP-SEP-25 | Alaa Tagi | Sprint 2 | Coursework/sprint 2#886Alaa-Tagi wants to merge 17 commits intoCodeYourFuture:mainfrom
Alaa-Tagi wants to merge 17 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Nov 25, 2025
Comment on lines
+30
to
+45
| 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; | ||
| } |
Contributor
There was a problem hiding this comment.
Change is optional.
Here are some test cases you can try when you have time.
countWords("constructor constructor");
countWords(" Hello World ");
Comment on lines
+62
to
+86
| test("totalTill calculates the total amount in pounds from the till object", () => { | ||
| const till = { | ||
| "1p": 10, | ||
| "5p": 6, | ||
| "50p": 4, | ||
| "20p": 10, | ||
| }; | ||
|
|
||
| expect(totalTill(till)).toBe("£4.10"); | ||
| }); | ||
|
|
||
| // Additional test cases | ||
| test("totalTill returns £0.00 for an empty till", () => { | ||
| const till = {}; | ||
|
|
||
| expect(totalTill(till)).toBe("£0.00"); | ||
| }); | ||
|
|
||
| test("totalTill handles tills with only one type of coin", () => { | ||
| const till = { | ||
| "100p": 5, | ||
| }; | ||
|
|
||
| // d) Write a test for this function to check it works and then fix the implementation of totalTill | ||
| expect(totalTill(till)).toBe("£5.00"); | ||
| }); |
Contributor
There was a problem hiding this comment.
Can your function pass all these tests?
cjyuan
reviewed
Nov 27, 2025
Contributor
cjyuan
left a comment
There was a problem hiding this comment.
Changes are good.
It's best practice to also respond to each of reviewer's comments.
Comment on lines
+17
to
+19
| recipe.ingredients.forEach(ingredient => { | ||
| console.log(ingredient); | ||
| }); No newline at end of file |
Contributor
There was a problem hiding this comment.
This work. Could also explore Array.prototype.join().
Comment on lines
+22
to
31
| if (firstEq === -1) { | ||
| // No "=" found → key with empty value | ||
| key = decodeURIComponent(pair); | ||
| value = ""; | ||
| } else { | ||
| key = decodeURIComponent(pair.slice(0, firstEq)); | ||
| value = decodeURIComponent(pair.slice(firstEq + 1)); | ||
| } | ||
|
|
||
| queryParams[key] = value; |
Contributor
There was a problem hiding this comment.
Could also consider performing the decoding step on line 31.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Learners, PR Template
Self checklist
Changelist
I have completed the tasks required in this sprint.
Questions
No questions.