-
-
Notifications
You must be signed in to change notification settings - Fork 195
Sheffield | May-2025 | Waleed-Yahya Salih-Taha | Sprint1 #638
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
2. logged the value of num and run it.
2. fixed the error by changing the declaration of age to 'let', and reassignment.
…ared. 2. to fix it , I declared the variable before using it in console.log
…umber while it's a string. 2. To fix this error, we need to convert the `cardNumber` to a string before using the `slice` method.
…s with a digit. 2. To fix this error, I renamed the variable to start with a letter or an underscore.
2. Ran the code and identified the line 7 where the error is coming from . 3. Identified all the lines that are variable reassignment statements. 4. Identified all the 5 lines that are variable declarations. 5. Described what the expression Number(carPrice.replaceAll(",","")) is doing. 6. corrected the code.
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 name the project in the PR title "test branch"?
// There are 5 variable declarations in this program: | ||
// 1. `movieLength` on line 1 | ||
// 2. `remainingSeconds` on line 3 | ||
// 3. `totalMinutes` on line 4 | ||
// 4. `remainingMinutes` on line 6 | ||
// 5. `totalHours` on line 7 | ||
|
||
// b) How many function calls are there? | ||
// There are no function calls in this program. All operations are performed using arithmetic operators and string interpolation. |
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 5 variable declarations and more than 0 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.
we declare a variable using (let & const). how come we have more than 5 variable declaration?
we only have 4 if we are talking about the given code not the corrected one.
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 counted 6 const
in the code at lines 1-9 in Sprint-1/3-mandatory-interpret/2-time-format.js
.
// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): removes the trailing 'p' from the string, resulting in "399". | ||
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): pads the string with leading zeros to ensure it has at least 3 characters, resulting in "399" (no change needed here since it already has 3 characters). | ||
// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds part of the string by taking all characters except the last two, resulting in "3". | ||
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumber |
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.
The description at line 33 seems incomplete.
On separate note, 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.
.padEnd(2, "0") ensures that a string is at least 2 characters long by padding it with "0" on the right.
yes, we need .padEnd(2, "0") to make sure there are always two digits to work with.
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.
Have you tried executing the script without padEnd(2, "0")
using different values of penceString
to validate your expectation?
I have now changed the name to sprint1 |
Learners, PR Template
Self checklist
Changelist
In this PR I have worked through and fixed the key exercises and checked the mandatory Errors plus interpreted them into corrected and executable code.
Questions
Ask any questions you have for your reviewer.