Skip to content

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

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

AlanGit-debug2604 wants to merge 24 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 92182be
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6ab4d3898e7f7b0008c1df58
😎 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.

Comment thread Sprint-2/1-key-exercises/4-random.js Outdated
// 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

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.

Done. Lines 18 and 19 say what num is.

Comment thread Sprint-2/2-mandatory-errors/2.js Outdated

//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).

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.

Done. ReferenceError is right, and line 10 answers the let question.

Comment thread Sprint-2/2-mandatory-errors/3.js Outdated
// 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?

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.

My very initial prediction was a last 4 card digit outcome; followed by a second glance and notice the code would result a TypeError.

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.

TypeError is right. Please write it in the file too, below your prediction on line 8. Did it match your prediction?

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.

Wrote the TypeError below my prediction line 8. Prediction matches.

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.

Done. Line 9 has it now.

Comment thread Sprint-2/2-mandatory-errors/4.js Outdated
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?

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.

It was a SyntaxError.

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.

SyntaxError is right. Please add it to your comment on line 1 too.

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.

Thanks. Change is saved, staged, and committed.

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.

Done. Line 1 has it now.

// 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.

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.

Line adjusted. Answers in a) to d) now correspond to the right lines.

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 line numbers are right now.

// 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.

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.

No. replaceall("," , "") does not removes spaces. The 2nd argument is to replace each match with and empty string. Comment in code corrected accordingly - not mentioning remove spaces.

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. Line 33 is correct now.

// 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?

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.

const movieLength = -90 prints "0:-1:-30" and const movieLength = -90.5 prints "0:-1:-30.5"

The code does not work for all values:
It does not pad single digits with a leading zero;
It does not validate to reject negative or decimal input.

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. f) is complete now.


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"?

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.

Copy that. For "399" length of 3 characters, .substring (paddedPenceNumberString.length - 2)' returns substring(1)` . Given zero indexing, therefore should return "99"

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, substring(1) gives "99". Lines 17 to 19 explain it well.

@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
@AlanGit-debug2604 AlanGit-debug2604 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 23, 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 there. Your answers in 1-percentage-change.js are all right now, and your answer to f) in 2-time-format.js is very thorough.

Three small things before I can mark this Complete:

  1. 3-to-pounds.js line 1: the p is missing from "399p" now. See my comment.
  2. 3.js and 4.js: you named the error in your replies. Please write it in the files too. Your answers should live in the files.
  3. Line endings, from my last review. Your formatting is right now, thanks. But 13 of your 14 files still use Windows line endings (CRLF), so GitHub still shows every line as changed. Format Document does not change line endings. Instead, open each file in VS Code, click CRLF in the blue bar at the bottom right, choose LF, and save. 1-count.js is already right.

Add the Needs Review label again once you have pushed.


// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"
const penceString = "399"; // initialises a string variable with the value "399p"

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.

Line 1 was "399p" before. Now it is "399", without the p. I think this changed by accident. Run the file. It prints £0.39, not £3.99. Please put the p back.

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.

Thanks for reminder. Saved the change, staged, and committed the 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.

Fixed. It prints £3.99 again.

@abdishakoor-dev abdishakoor-dev removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 23, 2026
@AlanGit-debug2604 AlanGit-debug2604 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 23, 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.

All three fixed, thanks. 3-to-pounds.js prints £3.99 again, and the error names are in 3.js and 4.js.

One last thing. 2-initials.js still has Windows line endings (CRLF). It is the only file left. Open it in VS Code, click CRLF in the blue bar at the bottom right, choose LF, and save.

Add the Needs Review label again once you have pushed, and I will mark this Complete.

@abdishakoor-dev abdishakoor-dev removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 24, 2026
@AlanGit-debug2604 AlanGit-debug2604 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 24, 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.

All fixed. Every file uses LF now, Prettier passes, and every file runs. Marking this Complete. Well done.

Two things for your next PRs. You don't need to change anything here:

  1. Variable names in JavaScript use camelCase, starting with a small letter. So in 4.js, twelveHourClockTime, not TweleveHourClockTime. Check the spelling of "twelve" too.

  2. You asked on Slack how to stop CRLF coming back. There are two settings:

    • In VS Code, press Ctrl + , and search for eol. Change Files: Eol from auto to \n. New files will then use LF. (The Prettier setting you ticked only chooses the formatter. It does not change line endings.)
    • In the terminal, run this once: git config --global core.autocrlf input. Git will then change CRLF to LF every time you commit.

    Please don't add a .gitattributes file to your coursework branch. It would be an extra file outside the Sprint-2 folder, so it would show in your PR. The two settings above fix it on your computer for every repo.

@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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 24, 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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants