Skip to content

London | 26-ITP-Sep | Chandaramani Gaire | Sprint 2 | Sprint 2 Coursework - #1575

Open
gaireprakash20-ops wants to merge 4 commits into
CodeYourFuture:mainfrom
gaireprakash20-ops:Sprint-2
Open

gaireprakash20-ops wants to merge 4 commits into
CodeYourFuture:mainfrom
gaireprakash20-ops:Sprint-2

Conversation

@gaireprakash20-ops

@gaireprakash20-ops gaireprakash20-ops commented Sep 22, 2026

Copy link
Copy Markdown

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-1039

Changelist

Answer the question and make changes per the question's requirements.

@netlify

netlify Bot commented Sep 22, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module ready!

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

@github-actions

This comment has been minimized.

@gaireprakash20-ops gaireprakash20-ops added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 22, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 22, 2026
@gaireprakash20-ops gaireprakash20-ops added the 📅 Sprint 2 Assigned during Sprint 2 of this module label Sep 22, 2026
@github-actions

This comment has been minimized.

@gaireprakash20-ops gaireprakash20-ops added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 22, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 22, 2026
@gaireprakash20-ops gaireprakash20-ops changed the title London | 26-ITP-Sep | Chandaramani Gaire | Sprint 2 | Complete Sprint 2 Coursework London | 26-ITP-Sep | Chandaramani Gaire | Sprint 2 | Sprint 2 Coursework Sep 22, 2026
@github-actions

This comment has been minimized.

@gaireprakash20-ops gaireprakash20-ops added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 22, 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 1-percentage-change.js answers a) to e) are all right, and you fixed the missing comma on line 5 too. 3-paths.js also works well, because you used lastIndexOf for ext.

I have left a hint on each line. These are the things to fix before I can mark this Complete:

  1. Six files stop with a SyntaxError, so none of their code runs: 0.js, 1.js, 2.js, 4.js, 1-percentage-change.js and 2-time-format.js. Each one has a comment that starts with /* but never ends. Add */ at the end of each /* comment. Then run each file with node to check.

  2. 2-mandatory-errors: your explanations are good, but the code in 1.js, 2.js, 3.js and 4.js still fails. Fix each one so it runs with no error.

  3. 2-initials.js lines 4 and 8.

  4. 4-random.js line 13: finish the breakdown.

  5. 2-time-format.js: answers c), d) and f).

  6. "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. Right now most of your files fail that check.

    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

    Fix point 1 first. Prettier cannot format a file that has a SyntaxError.

Add the Needs Review label again once you have pushed.

We don't want the computer to run these 2 lines - how can we solve this problem? No newline at end of file
/*This is just an instruction for the first activity - but it is just for human consumption
We don't want the computer to run these 2 lines - how can we solve this problem?
for single line we used // and for multiple line use /* 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.

Your idea is right. /* starts a comment over many lines. But a /* comment must also end, with */. Add */ at the end of line 3.

Then run node 0.js. It should print nothing and show no error. Five more files have the same problem.

const middleName = "Katherine";
const lastName = "Johnson";

const CKJ = "something"

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 task says you must not write C, K or J in your code. Line 4 has all three. Line 4 is not used anywhere, so you can delete it.

const initials = ``;

// https://www.google.com/search?q=get+first+character+of+string+mdn
const initials = `"${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}"`;

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.

Run the file. It prints "CKJ", with quote marks. The task wants CKJ. The quote marks come from the two " inside your backticks. What happens if you delete them?


// In this exercise, num represent the value integer number between 1 to 100.
//Math.random generates a random decimal number from 0 up to 1, but not including, 1.
// down to the nearest whole number (integer).

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 13 starts in the middle of a sentence. I think it is about Math.floor. Please finish it.

Two steps are also missing. Math.random() * (maximum - minimum + 1) is Math.random() * 100. That gives a decimal from 0 up to 100. Math.floor then makes it a whole number from 0 to 99. So what does + minimum do at the end?

age = age + 1;

/* In this case age is not const means variable is not reassigned so that,
we throws a TypeError: Assignment to constant variable.2

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.

You found the right message: TypeError: Assignment to constant variable. But the file still stops with that error. Which keyword lets you give a variable a new value later? Use it on line 3.

@@ -1,9 +1,12 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);
const last4Digits = string(cardNumber).slice(-4);

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 on line 11 is right. Now run node 3.js. It stops with a new error: ReferenceError: string is not defined. In JavaScript, capital letters matter in names. Is string the same as String?

@@ -1,2 +1,3 @@
const 12HourClockTime = "8:53pm";
const 24hourClockTime = "20:53";
/*variable is not start with number show 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.

Your reason is right. A variable name cannot start with a number. Now rename the two variables on lines 1 and 2, so the file runs. For example, you can move the number to the end of the name, or write it as a word.


// c) Using documentation, explain what the expression movieLength % 60 represents
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
/*The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend.

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.

This is what % does in general. In this program, movieLength % 60 gives 24. Are those 24 seconds, minutes or hours? Write what the 24 means in this program.

/*The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend.

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
/* This expression convert movies time second into minutes dividend by 60 second.

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.

Dividing by 60 is the second step. First, (movieLength - remainingSeconds) takes the 24 leftover seconds away. Why do that before dividing by 60? Try 8784 / 60 in node and look at the result.

We can change this name as movieTime.

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
/* In this section we can only use the positive natural numbers but if we put numbers that divide by 60 without a remainder get the exact time like 10, 20 50.

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.

You are right that positive whole numbers work. Now try -90 and 90.5 as movieLength. What does the program print each time? Would you show a time like that? Write what you see.

Also, 10, 20 and 50 cannot be divided by 60 with no remainder. Which numbers can?

@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 23, 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