Skip to content

London | 26-ITP-Sep | Alan Mak | Sprint 2 | Coursework - #1570

Open
AlanGit-debug2604 wants to merge 9 commits into
CodeYourFuture:mainfrom
AlanGit-debug2604:coursework/sprint-2
Open

AlanGit-debug2604 wants to merge 9 commits into
CodeYourFuture:mainfrom
AlanGit-debug2604:coursework/sprint-2

Conversation

@AlanGit-debug2604

@AlanGit-debug2604 AlanGit-debug2604 commented Sep 21, 2026

Copy link
Copy Markdown

Alan Mak, 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

CYF-1039

Changelist
Work done in files in coursework, namely in folders:
1-key-exercises
2-mandatory-errors
3-mandatory-interpret and
4-stretch-explore

@netlify

netlify Bot commented Sep 21, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module ready!

Name Link
🔨 Latest commit 5bd8824
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6ab1b94554d11f00086738ee
😎 Deploy Preview https://deploy-preview-1570--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.

@AlanGit-debug2604 AlanGit-debug2604 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. labels Sep 21, 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.

Your 3-paths.js works for any file name, because you used lastIndexOf for ext too. Every file runs with no errors.

Some answers are missing or need another look before I can mark this Complete:

  1. 1-key-exercises/1-count.js has no answer yet. Describe what line 3 is doing, and what = does there.

  2. 1-key-exercises/4-random.js line 16: say what num is at the end. See my comment.

  3. 2-mandatory-errors/2.js, 3.js and 4.js: add the name of the error. 2.js and 3.js need a little more too. See my comments.

  4. Delete the old code you commented out: 1.js lines 6 and 7, 2.js lines 8 and 9, 4.js lines 1 and 2, and 1-percentage-change.js line 5. Git keeps the old version for you. Keep your explanations.

  5. 3-mandatory-interpret/1-percentage-change.js: the line numbers in a) to d), and answer e). See my comments.

  6. 3-mandatory-interpret/2-time-format.js answer f): try more values. See my comment.

  7. 3-mandatory-interpret/3-to-pounds.js line 17. See my comment.

  8. Formatting. "My changes follow the style guide" is on your checklist, and consistent formatting is part of it. The tool that does it is called Prettier. It sets spacing and indentation to one agreed style. Then a reviewer only sees the changes you meant to make. At the moment 12 of your 13 files fail that check.

    Your files also have Windows line endings. So GitHub shows every line as changed, even lines you did not touch. Prettier fixes this too.

    Prettier comes with the CYF extension pack from onboarding. If you are not sure you have it, open VS Code, go to Extensions, and search for CodeYourFuture Extension Pack: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack

    Then open each file you changed, right click in the editor, and choose Format Document. Pick Prettier if VS Code asks. Save, commit and push. To format every time you save, follow the format on save steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md

Add the Needs Review label again once you have pushed.

// The value inside Math.floor() is its argument. The return value of this argument is expression within the yellow parenthesis.
// The whole expression of variable "num" is that a float generated by method Math.random() is multiplied by return value of the range specified by value between declared variable by key word constant.
// The method Math.floor() then return greatest integer of the value of this product.
// And finally plus the value of minimum variable declared.

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 steps are in the right order. Now finish with what num is. What is the smallest value it can be? What is the largest? Run the file a few times to check.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

num is a random integer between maximum and minimum inclusive.
The smallest value of 'num' can be 1


//console.log(`I was born in ${cityOfBirth}`);
//const cityOfBirth = "Bolton";
//The error is that the variable should be declared as a constant before it is used in the console.log statement.

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.

The order is the problem, you are right. Does it need to be a constant, though? Would line 4 still work with let instead of const?

The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one is this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is a ReferenceError.

In this code, the key word does not need to be constant, it can be let - if this is the case the variable city0fBirth can be reassigned in other lines - instead of constant (which cannot reassign variable).

// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
// Expectation about the error : cardNumber is assigned a number value, a .slice function does not work on number
// The constant last4Digits should be assigned to a String (cardNumber) to perform .slice function.

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 prediction is clear. What happened when you ran it? Did it match your prediction?

The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one did you get?

const 24hourClockTime = "20:53";
// const 12HourClockTime = "8:53pm";
// const 24hourClockTime = "20:53";
// An identifier cannot start with a numberical value

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.

Right reason. The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one is this?

// Read the code and then answer the questions below

// a) How many function calls are there in this file? Write down all the lines where a function call is made
// There are five function calls in this code in lines 4, 5, and 10

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 answers use the line numbers of the original file. Your file has two extra lines now. The fixed line is on line 7, and console.log is on line 12. Delete line 5 and the empty line after it. Then check your line numbers in a) to d) again.

// On lines 7 and 8, variables priceDifference and percentageChange are declared by const.

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
// To remove comma as a punctuation and space such that the string is ready turn into a number by method Number. No newline at end of file

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.

Does this remove spaces too? Look at the first argument of replaceAll.

// The variable result represents length of movie in H:M:S format. A better variable name can be movieLength_HMS

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
// A value of movieLength 3661 will return a result of 1:1:1 where the place value for second does not conforms with leading zero time format. No newline at end of file

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.

Good, the missing zeros are one problem. Now try -90 and 90.5. What does each one print? Would you show a time that way?


const pence = paddedPenceNumberString
.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0"); // declares variable for pence. Argument -2 of .substring method returns the last two characters.

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.

The argument here is paddedPenceNumberString.length - 2, not -2. What number is that for "399"?

@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 22, 2026
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 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