Skip to content

Conversation

@Alaa-Tagi
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I have completed the tasks required in this sprint.

Questions

No questions.

@Alaa-Tagi Alaa-Tagi added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. labels Nov 24, 2025
Comment on lines 16 to 20
${recipe.ingredients[0]
}
${recipe.ingredients[1]}
${recipe.ingredients[2]}
${recipe.ingredients[3]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach works only when there are exactly 4 ingredients.
Can you figure out a more general approach that works on any number of ingredients?

Comment on lines 22 to 24
}
queryParams[key] = value;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that in real querystring, both key and value are percent-encoded or URL encoded in the URL. For example, the string "5%" will be encoded as "5%25". So to get the actual value of "5%25" (whether it is a key or value in the querystring), we should call a function to decode it.
May I suggest looking up any of these terms, and "How to decode URL encoded string in JS"?

if (!Array.isArray(items)) {
throw new TypeError('Input must be an array');
}
const tallyResult = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the following function call returns the value you expect?

tally(["toString", "toString"]);

Suggestion: Look up an approach to create an empty object with no inherited properties.

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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

countWords("constructor constructor");
countWords("          Hello    World      ");

Comment on lines 9 to 14
test("calculateMode is a function ,returns the most frequent number", () => {
const nums = [1, 2, 2, 3, 4];

expect(typeof calculateMode).toBe("function");
expect(calculateMode(nums)).toBe(2);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The objective of this stretch exercise is to decompose the code in the calculateMode function in mode.js into two functions.

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");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can your function pass all these tests?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 25, 2025
@Alaa-Tagi Alaa-Tagi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Data-Groups The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants