-
-
Notifications
You must be signed in to change notification settings - Fork 272
Glasgow | May-2025 | Salah Ahmed | Sprint-1 #476
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
Conversation
…ble updates and string manipulation
cjyuan
left a comment
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.
- Why not practice "committing files one by one, on purpose, and for a reason"?
- In VSCode, you can select which file to stage, and commit only the staged file.
See: https://www.youtube.com/watch?v=z5jZ9lrSpqk&t=705 (At around 12:50 minute marker, the video shows how to stage a single file).
- Explanations are clearly written. I only have few suggestions and a question.
| // Line 3 is updating the value of the count variable by adding 1 to its current value. The = operator is used for assignment, meaning it takes the value on the right (count + 1) and assigns it to the variable on the left (count). | ||
| // The expression count + 1 calculates the new value, and then the = operator assigns this new value back to the count variable. | ||
| // The count variable now holds the value 1, which is the result of the initial value (0) plus 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?
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.
Yes count++;
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.
What is the programing term for such operation?
| // The variable num represents a random integer between the values of minimum (1) and maximum (100), inclusive. | ||
| // The expression Math.random() generates a random floating-point number between 0 (inclusive) and 1 (exclusive). |
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 can also use the concise and precise interval notation to describe a range of values.
For example, we can say Math.random() returns a random number in the interval [0, 1).
| // a) There are 2 function calls in this file: | ||
| // 1. `carPrice.replaceAll(",", "")` on line 4 | ||
| // 2. `priceAfterOneYear.replaceAll(",", "")` on line 5 |
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.
There are more than 2 function calls.
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.
Yes, I have added the 3rd function
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.
There are more then 3 function calls.
I could not see any new changes made to the file Sprint-1/3-mandatory-interpret/1-percentage-change.js.
| // .substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): | ||
| // extracts the last two characters (the pence part) and pads it with trailing zeros to ensure it has 2 characters, resulting in "99" |
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?
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.
I have refactored the code for improved readability and remove unnecessary padding logic
const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
No need to padEnd here since paddedPenceNumberString always has at least 3 digits
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.
Your understanding is correct. Change is not needed. The task only asks you to describe how the code works.
Learners, PR Template
Self checklist
Changelist
I have solved all issues in sprint 1