Skip to content

Cape Town | 26-ITP-Sep | Thabisile Malindi | Sprint 2 | Coursework: Sprint 2 - #1631

Open
Thabimalindi wants to merge 2 commits into
CodeYourFuture:mainfrom
Thabimalindi:Coursework-Sprint-2
Open

Thabimalindi wants to merge 2 commits into
CodeYourFuture:mainfrom
Thabimalindi:Coursework-Sprint-2

Conversation

@Thabimalindi

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

Replace this line with the Task code (e.g. CYF-1039).

Changelist

  • Completed the key exercises.
  • Fixed and explained the mandatory errors.
  • Completed the interpretation exercises.
  • Explored JavaScript in the Chrome console using alert and prompt.
  • Practised working with variables, strings, methods, operators and functions.

@netlify

netlify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cyf-onboarding-module ready!

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

Copy link
Copy Markdown

Your PR description is incomplete.

You filled out a template (that starts "Learners, PR Template") when you created this PR - you can see it at the top of this page.

Make sure to fill in all fields in the template.

Please ensure:

  • All self checklist items are ticked (with a [x])
  • The "Changelist" section is filled with details of what your PR does.
  • The "Questions" section is either filled in (if you have questions) or is removed (if you don't).

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@iscmiguelsamaniego iscmiguelsamaniego left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Excellent work overall! You consistently provide clear, accurate breakdowns, handle data types and debugging well, and think about edge cases.

Quick question: Which concept you've practiced so far do you feel has helped you grow the most?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job! Your explanation of line 3 and the assignment operator = is very clear and precise.
Just one quick question: Is there an even shorter shorthand way to write count = count + 1 in JavaScript?

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.

Thank you so much. Yes it's count++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perfect! That's a very clean and clever use of template literals and bracket notation.

Quick question: Is there another built-in string method (besides bracket notation) you could use to get the first character of each string? Why might you choose one over the other?

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.

Yes, I could also use charAt(0) to get the first character of each string. For example, firstName.charAt(0). I used bracket notation because it is shorter and easier for me to read, but charAt() is also useful because it clearly shows that I am getting a character from the string.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Spot on! This is a very clean and precise use of lastIndexOf and slice.

Quick question: What would happen if the path didn't have a file extension (for example, just a folder name)? How might you handle that edge case?

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 think if there is no file extension, lastIndexOf(".") would return -1. I could check for that first, and if it returns -1, I would know that there is no extension.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great explanation! To answer your question: Math.random() is used whenever you need unpredictability, like in games, randomized lists, or security tokens.
The solution branch also uses console.assert(). How do you think using console.assert() helps test code automatically compared to reading a console.log?

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.

Thank you

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 think console.assert() helps because it checks if the result is what I expected automatically. If the result is wrong, it shows an error, while with console.log() I would have to check the result myself.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job spotting and fixing the TypeError! Changing const to let is the exact right solution since the variable needs to be reassigned.
Quick question: Why do you think JavaScript throws an error if you try to reassign a const variable?

@Thabimalindi Thabimalindi Oct 1, 2026 •

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 think JavaScript gives an error because const means the value should not be changed. Once I give it a value, I cannot assign a new value to it. If I need the value to change, I should use let.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job finding and fixing the reference error! Moving console.log below the variable declaration is the right fix.
Quick question: Why do you think JavaScript doesn't let you use a variable declared with const before it is initialized?

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 think it is because the const variable has not been given a value yet. JavaScript needs it to be declared and initialized first before I can use it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job! Your prediction, debugging process, and use of console.assert() are spot on.

Quick question: Do you think last4Digits needs to be converted back to a number for typical use cases (like showing the last 4 digits on a receipt), or is keeping it as a string actually better? Why?

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 think keeping it as a string is better because we are only displaying the last 4 digits, not doing calculations with them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job! You successfully used valid variable names that follow the naming rules by starting with letters.

Quick question: Besides letters, what are the other two special characters that JavaScript allows you to use at the beginning of a variable name?

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.

The other two special characters are the underscore _ and the dollar sign $. So a JavaScript variable name can start with a letter, _, or $.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job! Your breakdown of function calls, variable declarations, reassignments, and how replaceAll works with Number is very thorough and accurate.
Quick question: Is there any other method in JavaScript besides replaceAll() that you could use to remove characters from a string, or is this the best approach for commas?

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.

Yes, I could also use replace() to remove a comma. I think replaceAll() is better here because it will remove all the commas if the number has more than one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job! Your breakdown is extremely thorough, and I love your suggestion to rename result to formattedMovieLength, as well as your attention to edge cases like decimals.

Quick question: If movieLength could include decimals, what built-in Math method could you use to ensure you are always working with whole numbers?

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 could use Math.floor() to remove the decimal part and make sure I am working with a whole number.

@Thabimalindi Thabimalindi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Your PR description is incomplete.

You filled out a template (that starts "Learners, PR Template") when you created this PR - you can see it at the top of this page.

Make sure to fill in all fields in the template.

Please ensure:

  • All self checklist items are ticked (with a [x])
  • The "Changelist" section is filled with details of what your PR does.
  • The "Questions" section is either filled in (if you have questions) or is removed (if you don't).

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants