-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
NW6 | Rabia Avci | JS1 Module | [TECH ED] Complete week 1 exercises | Week1 #130
base: main
Are you sure you want to change the base?
Conversation
percentage-change time-format
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 mostly really good but there are a few mistakes. If you can, please reveiw my comments and make sure you understand why you slipped up. Need to get the foundations right!
|
||
// answer | ||
// we turned it comment with // for human consumption |
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.
👍
// const age = 33; | ||
// age = age + 1; | ||
|
||
let age = 33; |
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.
👍
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
|
||
// By declaring cityOfBirth before using it in the template string, we can be able to print the string "I was born in Bolton" without any issues. |
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.
Very good and well explained
// The last4Digits variable should store the last 4 digits of cardNumber | ||
// However, the code isn't working | ||
// Make and explain a prediction about why the code won't work | ||
// Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
|
||
// answer | ||
// The slice method is used on strings, not numbers. with "" made string then slice function worked |
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.
Very well said!
|
||
const twelve_HourClockTime = "20:53"; | ||
const twentyFour_hourClockTime = "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.
👍
// c) Using documentation on MDN, explain what the expression movieLength % 60 represents | ||
|
||
// * movieLength % 60 represents the remaining seconds after dividing movieLenght by 60 (seconds) |
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.
Makes sense :)
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
|
||
//*const totalMinutes = (movieLength - remainingSeconds) / 60; It calculates total minutes by dividing movieLength - remainingSeconds by 60 |
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.
👍
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
||
//* formattedMovieLength |
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.
Nice name
// f) Think about whether this program will work for all values of movieLength. | ||
// Think of what values may cause problems for the code. | ||
// Decide the result should be for those values, then test it out. | ||
// Can you find any values of movieLength which don't give you what you'd expect? | ||
|
||
//*This program will work for all positive integer values of movieLength. However, it may not handle negative values. Like movieLength = -8784 | ||
// for negative values we can add a conditional check and take the absolute value. |
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.
Makes sense However, taking the absolute value of the var might cause confusion. Normally, you'd either throw an exception or return an empty value. It's important to be predicatable where possible or at least clearly document that the function behaves in an odd way and why
// Line 14 Extracts the pounds part from paddedPenceNumberString by taking characters from the beginning up to the length of paddedPenceNumberString - 2. | ||
// Line 21 Extracts the last two characters (representing pence) from paddedPenceNumberString and then pads the result with trailing zeros using padEnd to ensure it has two characters. | ||
|
||
// Line 25 Prints the final formatted string by combining pounds, a dot, and pence, with a pound sign (£) at the beginning. |
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.
Makes sense!
Self checklist
Changelist
Ive tried to solve JS1-week 1 exercises. They were a bit hard to understand. I tried to break down each line to make it easier to understand.
Questions
padStart and padEnd are not very clear yet in my mind.