London|26-ITP-January|Alexandru Pocovnicu|Sprint 2|Acoursework #921
London|26-ITP-January|Alexandru Pocovnicu|Sprint 2|Acoursework #921alexandru-pocovnicu wants to merge 14 commits intoCodeYourFuture:mainfrom
Conversation
…lay function questions
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.
3 similar comments
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.
This comment has been minimized.
This comment has been minimized.
| // =============> Write your prediction here: all 3 logs will be '3' | ||
|
|
||
| const num = 103; | ||
| // const num = 103; |
There was a problem hiding this comment.
Note:
Deleting the global num is optional. Within the function block, num is resolved to the parameter num.
If you are interested in the topic, you can looking up these two concepts, identifier scope and identifier resolution, in the context of JavaScript programming. ChatGPT can give a good explanation.
There was a problem hiding this comment.
thank you , i did indeed think wrongly that if a globally declared variable and a parameter shared the same name they would be the same thing
| // Use the MDN string documentation to help you find a solution | ||
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
| function upperSnakeCase(str){ | ||
| return str.toUpperCase().split(" ").join("_") |
There was a problem hiding this comment.
Note: The two string methods .replace() and .replaceAll() can probably perform better on this task.
| const minutes = time.slice(-2); | ||
| if (hours === 0) { | ||
| return `12:${minutes} am`; | ||
| } | ||
| if (hours === 12) { | ||
| return `12:${minutes} pm`; | ||
| } | ||
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| return `${hours - 12}:${minutes} pm`; | ||
| } | ||
| return `${time} am`; | ||
| } |
There was a problem hiding this comment.
Can you make the format of the returned value more consistent?
Currently the formats of the return value of formatAs12HourClock("01:23") and formatAs12HourClock("13:23") are not quite the same.
|
thank you |
|
Changes look good. Well done. |
Learners, PR Template
Self checklist
Changelist
In this repo I have predicted errors, interpreted error messages, debbuged and implemented functions according to requrements