-
-
Notifications
You must be signed in to change notification settings - Fork 195
West Midlands | ITP-May - 25| Jonathan Boahene | Sprint-1 |Module-Structuring-and-Testing-Data #663
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
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.
Explanation is very clear! Great job.
I just have a few questions.
|
||
/*Line 3 is reassigning variable count with a new value, in this case we're saying add 1 to whatever we already have in count, | ||
and so by using the console.log before and after the reassignment the we can tell new value of count is 1 | ||
*/ |
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.
Operation like count = count + 1
is very common in programming, and there is a programming term describing such operation.
Can you find out what one-word programming term describes the operation on line 3?
/* SOLUTION | ||
a) **How many variable declarations are there in this program?** | ||
There are **5** variable declarations: `movieLength`, `remainingSeconds`, `totalMinutes`, `remainingMinutes`, `totalHours`, and `result`. |
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.
You listed all declared variables but miscounted them. :D
5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); | ||
Extracts the last two characters for the pence part (e.g., from "399", it takes "99"). If there are fewer than two characters, it pads the result on the right with zeros. |
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.
Could we expect this program to work as intended for any valid penceString
if we deleted .padEnd(2, "0")
from the code?
In other words, do we really need .padEnd(2, "0")
in this script?
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
This pull request improves code readability and data formatting for Sprint 1 of Module-Structuring-and-Testing-Data.
I refactored programs to clearly convert and format values, such as transforming pence strings to pounds, formatting time values, and calculating percentage changes.
Each solution includes step-by-step breakdowns and explanations, ensuring the code is easy to follow and works correctly for different input cases.
Questions
Ask any questions you have for your reviewer.