Cape Town | 26-ITP-Sep | Thabisile Malindi | Sprint 2 | Coursework: Sprint 2 - #1631
Thabimalindi wants to merge 2 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
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:
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
left a comment
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Thank you so much. Yes it's count++;
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 usesconsole.assert(). How do you think usingconsole.assert()helps test code automatically compared to reading aconsole.log?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Great job spotting and fixing the
TypeError! Changingconsttoletis 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 aconstvariable?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Great job finding and fixing the reference error! Moving
console.logbelow the variable declaration is the right fix.
Quick question: Why do you think JavaScript doesn't let you use a variable declared withconstbefore it is initialized?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I think keeping it as a string is better because we are only displaying the last 4 digits, not doing calculations with them.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
The other two special characters are the underscore _ and the dollar sign
There was a problem hiding this comment.
Great job! Your breakdown of function calls, variable declarations, reassignments, and how
replaceAllworks withNumberis very thorough and accurate.
Quick question: Is there any other method in JavaScript besidesreplaceAll()that you could use to remove characters from a string, or is this the best approach for commas?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I could use Math.floor() to remove the decimal part and make sure I am working with a whole number.
|
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:
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. |

Learners, PR Template
Self checklist
Task code
Replace this line with the Task code (e.g. CYF-1039).
Changelist