Skip to content

Conversation

@carlosyabreu
Copy link

@carlosyabreu carlosyabreu commented Nov 8, 2025

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

This PR is the commit I've done for Sprint 2 Coursework that needs to be merged into CYF main branch

Questions

@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@carlosyabreu carlosyabreu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 8, 2025
@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

3 similar comments
@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@carlosyabreu carlosyabreu changed the title London | 25-ITP-September | Carlos Abreu | Sprint 2 | Module-Structuring-and-Testing-Data London | 25-ITP-September | Carlos Abreu | Sprint 2 | Coursework Nov 8, 2025
@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

1 similar comment
@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@carlosyabreu carlosyabreu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 8, 2025
@github-actions
Copy link

github-actions bot commented Nov 8, 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.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

@cjyuan
Copy link
Contributor

cjyuan commented Nov 9, 2025

The text in the "Questions" section still appear in the PR description.
May I suggest looking up how to comment text in Markdown encoded text?

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@carlosyabreu carlosyabreu added 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. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 9, 2025
@carlosyabreu
Copy link
Author

@cjyuan
After you labelled "Reviewed" I made a change and set "Needs review" but it doesn't show up so I deleted "Reviewed" label but realised it should be changed only by volunteers not me then I put "Reviewed" label back.
However "Needs review" continues not showing up on PR which I don't understand.
Maybe it takes time to refresh.
Thanks CJ Yuan

@cjyuan
Copy link
Contributor

cjyuan commented Nov 9, 2025

  • You can replace "Reviewed" by "Needs review" after making changes. The "Reviewed" label is meant only to inform the reviewee that response is expected.

  • Can you also respond to this inline comment (see pic)?

image

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@carlosyabreu
Copy link
Author

carlosyabreu commented Nov 9, 2025

Evening CJ Yuan

Sorry for late reply.
After reviewing my code on terminal I got the following output:
$node 2-case.js

I don't get "HELLO___THERE" but "HELLO_THERE".
Rather than 2 or 3 underscores I get just 1 underscore in capital letter between hello and there.
It trimmed out more than 1 space between hello and there leaving just 1 space between these 2 words.

That's my bad. Sorry!

@carlosyabreu carlosyabreu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Nov 9, 2025

No need to apologise. It's a learning process.

Can you figure out why your function is not working as expected and modify it accordingly so that it behaves what you expect?

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@carlosyabreu
Copy link
Author

carlosyabreu commented Nov 9, 2025

Hi @cjyuan

Actually I change the function name from toUpperSnakeCase() to toUpperCamelCase() as stated by requirement.
It converts all small letter into capital letter and trimmed out the space replacing it with underscore.
The file (2-cases.js) in the folder (Module-Structuring-and-Testing-Data/Sprint-2/3-mandatory-implement) after running node I get the following output:

// This ensures consistent results even if the input has extra spaces.
// I update the code and push it to GitHub (the 2nd console.log) without the HTML   of course. It passed all checks
// Does this solution answer your query?

function toUpperCamelCase(str) {
return str.trim().replace(/\s+/g, "_").toUpperCase();
}

// Example usage:
console.log(toUpperCamelCase(" hello there ")); // "HELLO_THERE"
console.log(toUpperCamelCase("hello       there")); // I get "HELLO_THERE" - The example stated by CJ Yuan volunteer
console.log(toUpperCamelCase("lord of the rings")); // "LORD_OF_THE_RINGS"
console.log(toUpperCamelCase("javascript is fun")); // "JAVASCRIPT_IS_FUN"

@carlosyabreu carlosyabreu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Nov 9, 2025

Can you explain why this code output A_B instead of A___B?

function toUpperCamelCase(str) {
   return str.trim().replace(/\s+/g, "_").toUpperCase();
}

console.log(toUpperCamelCase("A   B"));  

And if you were to change it so that it returns would A___B, how would you modify the code?

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@carlosyabreu
Copy link
Author

Q1: Can you explain why this code output A_B instead of A___B?
function toUpperCamelCase(str) {
return str.trim().replace(/\s+/g, "_").toUpperCase();
}
console.log(toUpperCamelCase("A B"));

A1: Because the regex /\s+/g replaces all consecutive spaces (no matter how many) with a single underscore.

Q2: And if you were to change it so that it returns would A___B, how would you modify the code?

A2: Making the output "A___B"

As we want one underscore per space, we should replace each space individually, not as a group.
That means removing the + quantifier.

We would change the function toUpperCamelCase(str) to look as bellow:

function toUpperCamelCase(str) {
return str.trim().replace(/\s/g, "_").toUpperCase();
}

console.log(toUpperCamelCase("A B")); // A___B

Actually, /\s/g matches each single whitespace separately.
Each space becomes an underscore, resulting in "A___B".

@carlosyabreu carlosyabreu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 9, 2025
@cjyuan
Copy link
Contributor

cjyuan commented Nov 9, 2025

Explanation is clear.

All good.

@cjyuan cjyuan 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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 9, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants