-
-
Notifications
You must be signed in to change notification settings - Fork 195
London | ITP-May-2025 | Halyna Kozlovska | Module-Structuring-and-Testing-Data | Sprint-1 #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Edit comment to better describe assignment in line 3.
Add logic (create initials from first, middle, and last name) to generate and log initials.
Add logic to get dir and ext parts of file path
add random number generation between given min and max; add step-by-step comments; add console output;
comment out text to prevent SyntaxError
change 'const' declaration to 'let' to allow reassignment; log the updated value
fix ReferenceError by declaring variable before use
fix TypeError by converting number to string before slicing
fix SyntaxError by renaming variables starting with numbers
add answers to all questions; correct syntax error in replaceAll()
add answers to all questions; fix variable name for clarity
add step-by-step explanation comments
add explanation for alert and prompt functions in Chrome console
add explanation of console object and its methods in Chrome DevTools
Hello Halyna, hope you are well. Thanks for submitting this sprint 1 course work for the structuring & testing data module. Have a few comments: |
// 1. Math.random() generates a decimal between 0 (inclusive) and 1 (exclusive) | ||
// 2. Multiply by (maximum - minimum + 1) to scale to the desired range size | ||
// 3. Math.floor() rounds down to get an integer from 0 up to range size minus 1 | ||
// 4. Adding minimum shifts the range so the lowest number is minimum, not zero | ||
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good explanation.
Extension question: what is the range of values that num
can take?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amundeep-Dhaliwal Thank you for your comment.
The value of num is an integer within the range from minimum to maximum, including both ends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, should have clarified.
What are the numeric values for the upper & lower limits for num
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amundeep-Dhaliwal The lowest value num will be minimum, and the highest - maximum, so minimum ≤ num ≤ maximum. This line of code creates a random integer in that range by scaling a decimal from Math.random(), rounding down, and adding minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amundeep-Dhaliwal Did I answer your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good Halyna, well done.
// Rename variables to valid identifiers because names cannot start with a number | ||
const ClockTime_12Hour = "08:53"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good practice for naming variables. It can be quite difficult sometimes!
In JS it is common to use camel case when naming variables e.g. Time12Hour
. In python it is common to use snake case when naming variables time_12_hour
. It is good practice not to mix the two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amundeep-Dhaliwal Thank you. I agree and will keep this in mind for future naming.
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
|
||
// Firstly, carPrice.replaceAll(",", "") removes all commas from the string | ||
// Then Number(...) converts the resulting string into a number type so it can be used in arithmetic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look good, thanks for the explanations.
// 1. The code correctly converts movieLength into hours, minutes, and seconds for positive values. | ||
// 2. It doesn’t handle zero or negative values properly—these cases need extra checks. | ||
// 3. Minutes and seconds may appear without leading zeros. | ||
// 4. To improve add validation to handle zero or negative inputs gracefully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These answers are good, it is nice to see that you are thinking about the edge cases for the code.
const pence = paddedPenceNumberString | ||
.substring(paddedPenceNumberString.length - 2) | ||
.padEnd(2, "0"); | ||
|
||
// 6. Output the formatted price in pounds and pence | ||
console.log(`£${pounds}.${pence}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This activity looks good.
@Amundeep-Dhaliwal Do I need to change the status to "Needs Review"? |
Learners, PR Template
Self checklist
Changelist
Questions
Ask any questions you have for your reviewer.