Skip to content

Conversation

@Fares-Bakhet
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.

Questions

No questions.

@Fares-Bakhet Fares-Bakhet 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 +17 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 will only work when there are exactly 4 ingredient.
Can you figure out a solution that could work for any number of ingredients?

Comment on lines +72 to +79
test("given invalid parameters like an array, returns false", function (){
const input = [1, 2, 3];
const propertyName = 'a';
const currentOutput = contains(input, propertyName);
const targetOutput = false;

expect(currentOutput).toEqual(targetOutput);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Arrays are objects in JavaScript, and they do have property names -- just not the same ones as objects.
Which keys do arrays have, and how does that affect how reliable your test is?

When testing whether the function handles arrays properly, try using a key that an array might
realistically contain
. Otherwise, you might get a passing test even if the function isn't checking for arrays at all.

Comment on lines +29 to 32
}

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"?

throw new Error("tally expects an array");
}

const counts = {};
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 +33 to +51
function countWords(str) {
const result = {};
if (!str || str.trim().length === 0) {
return result;
}
const words = str.split(" ");
for (const word of words) {
if (result[word] === undefined) {
result[word] = 1;
} else {
result[word] += 1;
}
}
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

When you you have time to test your implementation, here are some test cases you can use to check your implementation:

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

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