-
-
Notifications
You must be signed in to change notification settings - Fork 240
London | 25-ITP-September | Ammad Ur Rehman | Sprint 2 | 03 Complete Sprint 2 Coursework #786
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
| // c) What is the return value of pad is called for the first time? | ||
| // =============> write your answer here | ||
|
|
||
| // 00 |
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.
A common convention for indicating that a value is a string is to enclose it in double quotes. For example, "00".
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| let hours = Number(time.slice(0, 2)); | ||
| const minutes = time.slice(3, 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.
We can also extract the last two characters as time.slice(-2).
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.
Changes look great! Well done.
|
|
||
| return result; | ||
| } | ||
| return String(string).toUpperCase().replaceAll(" ", "_"); |
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.
If string is already a string, we don't have to convert it to a string before using the string methods.
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.
That's true but it didn't show up in the auto-complete, also given that JavaScript is a dynamically typed language without type safety, the parameter is any type, so I need to ensure that I am dealing with a String type otherwise it fails.
Learners, PR Template
Self checklist
Changelist
I completed all the exercises.
Questions
I understand why TypeScript exists. JavaScript should have been a statically typed language.