London | Jan2026 | Ihor Taradaiko | Sprint 2 | Coursework/sprint 2#989
London | Jan2026 | Ihor Taradaiko | Sprint 2 | Coursework/sprint 2#989ihortar wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
51e880d to
66ef47c
Compare
cjyuan
left a comment
There was a problem hiding this comment.
There are a few more exercises in Sprint-2/1-key-errors.
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
|
|
||
| // =============> write your prediction here - should show undefined as there are ";" after return inside the function |
There was a problem hiding this comment.
What do you expect from the following function calls?
function sum3(a, b) {
return
a + b;
}
function sum4(a, b) {
return a
+ b;
}
console.log(sum3(1, 2));
console.log(sum4(1, 2));
There was a problem hiding this comment.
Not the same result. You can test them, and use AI to find out why.
There was a problem hiding this comment.
Oh, I didn't know that! The JS auto considers there is ";" after return if there is nothing else in the row
| function toPounds(str) | ||
| { | ||
| // 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
| const penceStringWithoutTrailingP = str.substring( | ||
| 0, | ||
| str.length - 1 | ||
| ); | ||
|
|
||
| //2. removes "P" from the string | ||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| //3. Ensures the string is at least 3 characters long by adding 0 to the start | ||
| const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
|
|
||
| //4. Extracts everything except the last 2 digits of paddedPenceNumberString | ||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| return pence | ||
| } |
There was a problem hiding this comment.
Normally, code inside a block is indented one level deeper than the block itself.
You can also consider installing the prettier VSCode extension and then use the VSCode's "Format document" function" to automatically indent code.
There was a problem hiding this comment.
I actually have it, would be great to have the button in the UI, not in the right click
There was a problem hiding this comment.
Why not try completing the implementation of formatAs12HourClock(time)?
There was a problem hiding this comment.
That's never a good excuse!
|
In the PR description, can you update the Markdown syntax to make the PR description more like this?
Changelist
|
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good.
Well done.
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| const hours = Number(time.slice(0, 2)); | ||
| const minutes = time.slice(3, 5); |
There was a problem hiding this comment.
.slice(-2) is probably more expressive to mean "extract the last two characters".
There was a problem hiding this comment.
That's never a good excuse!
|
You didn't update the Changelist! |
Completed the following exercises:
Key Errors
Mandatory Debug
Mandatory Implement
Mandatory Interpret