Skip to content

London | 26-ITP-Sep | Rhoda Ajiroba | Sprint 3 | Course work - #1629

Open
codebyra wants to merge 2 commits into
CodeYourFuture:mainfrom
codebyra:coursework/sprint-3
Open

codebyra wants to merge 2 commits into
CodeYourFuture:mainfrom
codebyra:coursework/sprint-3

Conversation

@codebyra

Copy link
Copy Markdown

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

Task code

CYF-1053

Changelist

Completed the Sprint 3 JavaScript Fundamentals coursework, including debugging, implementation, code interpretation, and stretch exercises.

@netlify

netlify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cyf-onboarding-module ready!

Name Link
🔨 Latest commit 2c96140
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6abdfb5a07b0c00008609d48
😎 Deploy Preview https://deploy-preview-1629--cyf-onboarding-module.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
2 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 86 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codebyra codebyra added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 29, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nearly all of this is right. Your answers in the key-errors, debug and time-format files are all correct, and toUpperSnakeCase is a clear name.

One thing before I can mark this Complete:

  1. 3-to-pounds.js: see my comment on line 7.

Add the Needs Review label again once you've pushed.

// You will need to declare a function called toPounds with an appropriately named parameter.

// You should call this function a number of times to check it works for different inputs
function toPounds(pence) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your function works for numbers, but it is not the program this exercise asks for.

The exercise wants you to take the program in Sprint-2/3-mandatory-interpret/3-to-pounds.js and turn it into a function. That program:

  • takes a string like "399p"
  • gives back a string like "£3.99"

Your function takes a number, like 250, and gives back a number, 2.5. A price should show as £2.50.

Please open that Sprint 2 file. Put its code inside your toPounds function, and use the parameter in place of "399p". Then call the function with a few different inputs, for example "399p", "5p" and "2500p".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your function works now. A string goes in, and a string comes out. Good.

But this exercise had a different aim. The Sprint 2 code in Sprint-2/3-mandatory-interpret/3-to-pounds.js already changes pence to pounds, and it works. But it only works for one price, because "399p" is fixed on line 1. To change "5p" or "2500p", you would need to copy all the lines again.

A function solves this. When we need the same lines many times, we put them in a function. The part that changes each time becomes the parameter. Here, the part that changes is the pence amount. The steps stay the same.

So you did not need to write new steps. Your three lines do the same jobs as the Sprint 2 lines:

Job Your code Sprint 2 code
Remove the p line 8: Number(pence.replace("p", "")) lines 3 to 6: penceString.substring(...)
Split into pounds and pence line 9: penceNumber / 100 lines 8 to 16: padStart, substring, padEnd
Build the price line 10: `£${pounds.toFixed(2)}` line 18: `£${pounds}.${pence}`

You only needed to change two Sprint 2 lines:

  • Sprint 2 line 1, const penceString = "399p";, goes away. The parameter takes its place. If you call the parameter penceString, lines 3 to 16 work with no changes at all.
  • Sprint 2 line 18 uses console.log. In a function, change it to return.

The function looks like this:

function toPounds(penceString) {
  // Sprint 2 lines 3 to 16 go here, with no changes
  return `£${pounds}.${pence}`;
}

Now the same lines work for every price. toPounds("399p"), toPounds("5p") and toPounds("2500p") all use them. Only the value you pass in changes.

The rule: if you need the same lines many times, put them in a function. Make the part that changes a parameter.

@abdishakoor-dev abdishakoor-dev 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 29, 2026
@codebyra codebyra added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 1, 2026
@codebyra

codebyra commented Oct 1, 2026

Copy link
Copy Markdown
Author

@abdishakoor-dev Thank you for your comment. I have made the changes

@codebyra codebyra removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Oct 1, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. toPounds works now, so I'm marking this Complete. Please read my reply on line 7. It explains the aim of this exercise.

@abdishakoor-dev abdishakoor-dev 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 Oct 1, 2026
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