Skip to content

Conversation

@Fradoka
Copy link

@Fradoka Fradoka commented Jul 31, 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

Questions

@Fradoka Fradoka added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 31, 2025
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Aug 13, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Hi,

Remember to update the template when you open a new PR on github - you have left the default text there, so I don't know what the goal of this PR is.

You have made a good start on these tasks. I've left some comments for how you could improve them further.

showLineNumb = false;
showNoBlankNumb = true;
}else {
file = arg;

Choose a reason for hiding this comment

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

What happens if I want to pass multiple files in here? For example, using the * wildcard which expands to multiple files in the shell.

Your solution in wc seems a better approach

Choose a reason for hiding this comment

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

This seems to be fixed now - well done

}).join('\n');
}

console.log (content)

Choose a reason for hiding this comment

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

Be careful of formatting your code the same way. Can you see why this line is inconsistent with the rest of the file?

args.forEach(arg => {
if (arg === '-a') {
showAll = true;
} else if (arg !== '-1') {

Choose a reason for hiding this comment

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

This approach might cause problems in two cases:

  • What if the user does not want each output per line and wants it all on one line (like the original ls) app?
  • Assuming anything else is a directory might make it more difficult to add new options in the future.

Choose a reason for hiding this comment

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

This is fixed now - great

const totalBytes = validCounts.reduce((sum, c) => sum + c.bytes, 0);

let totalOutput = '';
if (showLines) totalOutput += `${totalLines} `;

Choose a reason for hiding this comment

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

There is some duplication here when you are printing totals and when you print single file output. Can you think of how to reduce this?

Choose a reason for hiding this comment

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

Great work

}

async function main() {
const counts = await Promise.all(files.map(countFile));

Choose a reason for hiding this comment

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

This is a very minor point, but when doing map we expect it to return a new array that is different from the input array. Instead of .map can you think of another array function that would make more sense to use here?

Choose a reason for hiding this comment

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

Good solution

@LonMcGregor LonMcGregor 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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 13, 2025
@Fradoka
Copy link
Author

Fradoka commented Aug 31, 2025

hi @LonMcGregor, i have now amended this cat, ls, and wc to address review.

@Fradoka Fradoka added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 31, 2025
@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

1 similar comment
@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Good work on updating these. The only thing left to work in is making sure that your cat can handle numbering multiple files

showLineNumb = false;
showNoBlankNumb = true;
}else {
file = arg;

Choose a reason for hiding this comment

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

This seems to be fixed now - well done

const lines = content.split('\n');

if (showNoBlankNumb) { // Number only non-blank lines
let counter = 1;

Choose a reason for hiding this comment

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

Try testing your updated solution with the numbering options on with multiple files now your app supports it. How would you expect it to work? If you compare your solution to the original cat, can you see a discrepancy?

args.forEach(arg => {
if (arg === '-a') {
showAll = true;
} else if (arg !== '-1') {

Choose a reason for hiding this comment

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

This is fixed now - great

}

async function main() {
const counts = await Promise.all(files.map(countFile));

Choose a reason for hiding this comment

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

Good solution

const totalBytes = validCounts.reduce((sum, c) => sum + c.bytes, 0);

let totalOutput = '';
if (showLines) totalOutput += `${totalLines} `;

Choose a reason for hiding this comment

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

Great work

@LonMcGregor LonMcGregor 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 Sep 1, 2025
@github-actions
Copy link

github-actions bot commented Sep 1, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

1 similar comment
@github-actions
Copy link

github-actions bot commented Sep 1, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

@Fradoka
Copy link
Author

Fradoka commented Sep 1, 2025

hi @LonMcGregor, amended my_cat.js to address review.

@Fradoka Fradoka added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 1, 2025
@LonMcGregor
Copy link

In my_cat.js why do you use two different counter variables? Is there a circumstance where you can be numbering both blank and non-blank lines at once where you would need to count these separately?

@LonMcGregor LonMcGregor 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 Sep 2, 2025
@Fradoka
Copy link
Author

Fradoka commented Sep 2, 2025

hi @LonMcGregor, i don't actually need 2 different counter variables as -b will overide -n so there won't be a time when i would need both set of numbering. i used 2 counters before to differentiate but a unique counter still does the job. i have now amended the code to address that.

@Fradoka Fradoka added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 2, 2025
@LonMcGregor
Copy link

@Fradoka It is worth considering the trade-offs here. Two counters would let you differentiate it, and maybe in a more complex app you might want to add features that require it, so it's good you considered this. But here it probably isn't necessary. Good work on this sprint task, it's done now!

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants