Skip to content

London | 26-ITP | Mars Adesina | Sprint 2 | Javascript Fundamentals - #1559

Open
marscancode wants to merge 43 commits into
CodeYourFuture:mainfrom
marscancode:coursework/sprint-2
Open

marscancode wants to merge 43 commits into
CodeYourFuture:mainfrom
marscancode:coursework/sprint-2

Conversation

@marscancode

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

Changelist

Completed all 4 sections of the sprint-2 coursework.

@github-actions

This comment has been minimized.

@marscancode marscancode 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
@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 21, 2026
@github-actions

This comment has been minimized.

@netlify

netlify Bot commented Sep 21, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module failed. Why did it fail? →

Name Link
🔨 Latest commit cae3793
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6ab144f92a8cf800088a0dec

@netlify

netlify Bot commented Sep 21, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module ready!

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

@marscancode marscancode added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label 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.

Good work on this sprint. Your prediction in 2-mandatory-errors/3.js is honest and clear. You say what you expected and what was different.

Four things to fix before I can mark it Complete:

  1. 1-key-exercises/4-random.js line 5: this line stops the file with an error. Remove it.
  2. 1-key-exercises/4-random.js line 14: the answer needs to say what num is. See my comment on that line.
  3. 2-mandatory-errors/1.js: the fix works, but the error and the reason are not written down.
  4. 1-key-exercises/3-paths.js line 18: ext only works for this one file name.

Also, "My code is consistently formatted" is on the checklist. The tool that does this 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 2-mandatory-errors/0.js fails 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

Open 0.js, right click in the editor, and choose Format Document. Pick Prettier if VS Code asks. Save and commit. 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
const maximum = 100;

const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
num = Math.floor(Math.random(0.9) * (100 - 1 + 1)) + 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.

Run node 4-random.js inside the Sprint-2/1-key-exercises folder. What is the first line of the error?

num is declared with const on line 4. A const cannot get a new value. Please delete line 5.

Comment thread Sprint-2/1-key-exercises/4-random.js Outdated
//console.log(num)
//output: random whole number

// So num is storing the value of a random number generated by the method Math.random this will be a number between zero and one that is then multiplied by 100 (100(maximum) -1(minimum) +1) and then whatever this number is, one is added on to that number and then finally the Math.floor method will round that number down to the nearest whole number add one and this final number is what is stored in the variable num.

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.

Two things in this answer.

First, you say one is added before Math.floor, and again after it. The + minimum happens once. Look at the brackets on line 4. Which happens first, Math.floor or + minimum?

Second, finish with what num is. What is the smallest value it can be? What is the largest?

// trying to create an age variable and then reassign the value by 1

const age = 33;
let age = 33;

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 fix is right. The exercise also asks for the error and the reason.

The starter had const age = 33; on this line. Add a comment with the first line of the error node printed. Then say in your own words why it happened.

Tip: the error in 1-key-exercises/4-random.js right now is the same one.

Comment thread Sprint-2/1-key-exercises/3-paths.js Outdated

// https://www.google.com/search?q=slice+mdn No newline at end of file
const dir = filePath.slice(0, lastSlashIndex);
const ext = base.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.

This gives .txt for file.txt. What does it give if base is photo.jpeg?

The number 4 only fits a name with four letters. How can you find where the . is, like you found the last / on line 13?

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.

slice(-4) still counts four characters from the end. What does it give for photo.jpeg?

The . is not always four characters from the end. On line 13 you used lastIndexOf to find the last /. Can you do the same for the .?

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.

I have made the changes and pushed it now. I didn't think about the slice method not working for every extension type because they differ in length but after reviewing my code on line 13, I understand now why using the lastindex of method for the ext variable is correct here! Thanks so much Abdi!

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.

That's the one. Your comment on line 19 explains 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 21, 2026
@marscancode marscancode added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 21, 2026
@marscancode

Copy link
Copy Markdown
Author

Thankyou for reviewing my work Abdi! I have fixed my code to be in line with the things you pointed out and i've pushed the changes so hopefully all should be correct now.

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

Thank you for the quick fixes. Your answer in 4-random.js is now clear. It gives the order and the range 1 to 100.

One thing left: ext in 1-key-exercises/3-paths.js. See my reply on line 18.

Add the Needs Review label again once you have pushed.

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

ext is fixed. It gives .txt for file.txt and .jpeg for photo.jpeg.

One small note, no need to change it now. Line 12 has an extra photo/ in the path. So the //44 comment on line 13 is out of date.

Marking this Complete. Well done.

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