Skip to content

Sheffield | May-2025 | Waleed-Yahya Salih-Taha | DataGroup-sprint 2 #672

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
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

Bluejay600
Copy link

@Bluejay600 Bluejay600 commented Jul 21, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

this PR gives a short set of requirements about a function. and You will need to implement, interpret and and sometimes fix a function based off this set of requirements

Questions

Ask any questions you have for your reviewer.

@Bluejay600 Bluejay600 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Participant to add when requesting review labels Jul 23, 2025
@Bluejay600 Bluejay600 changed the title DataGroup-sprint 2 Sheffield | May-2025 | Waleed-Yahya Salih-Taha | DataGroup-sprint 2 Jul 24, 2025
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
return false;
}
return Object.prototype.hasOwnProperty.call(obj, key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also use Object.hasOwn(obj, key).


// Given invalid parameters like an array
// When passed to contains
// Then it should return false or throw an error
test("contains on array returns false", () => {
expect(contains([1, 2, 3], 'a')).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

contains([1, 2, 3], "a") could also return false because "a" is not a property (or key) of [1, 2, 3].
However, "0", "1", "2" are keys of [1, 2, 3], so it is better to specify the test as
expect(contains([1, 2, 3], "1")).toBe(false); (to ensure you are checking what you describe)

Copy link
Contributor

Choose a reason for hiding this comment

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

The file Sprint-2/implement/querystring.js (which contains the implementation of the function) was not updated.

Comment on lines +1 to +9
function tally(arr) {
if (!Array.isArray(arr)) {
throw new Error("Input must be an array");
}
return arr.reduce((acc, item) => {
acc[item] = (acc[item] || 0) + 1;
return acc;
}, {});
}
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"]);

Copy link
Contributor

Choose a reason for hiding this comment

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

What is this file for?

Comment on lines +36 to +48
const words = cleanedStr.split(/\s+/);

// Create an object to store word counts
const wordCount = {};

for (let word of words) {
if (wordCount[word]) {
wordCount[word]++;
} else {
wordCount[word] = 1;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if your function returns what you expect in the following function calls?

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


// Optional: Sort the results by frequency (most common first)
const sortedWordCount = Object.fromEntries(
Object.entries(wordCount).sort((a, b) => b[1] - a[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

In (a, b) => b[1] - a[1], it is not clear what the 2nd element of the parameters represents.

Can you think of a way to make the code more readable? (Hint: Use array destructuring on the parameters).

total += coin * quantity;
for (const [coin, quantity] of Object.entries(till)) {
// Remove the "p" and convert to number
const coinValue = parseInt(coin.replace("p", ""), 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you find out why the following statement work equally well (compare to the statement at line 12)?

 const coinValue = parseInt(coin); 

Copy link
Contributor

Choose a reason for hiding this comment

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

Sprint-3/quote-generator/index.html does not belong to Sprint-2. Can you revert the change to this file?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review 📅 Sprint 2 Assigned during Sprint 2 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants