Closed ghost closed 4 years ago
All clocks I've ever seen pad the minutes, so it looks like 4:02pm
instead of 4:2pm
.
Padding the start hour is optional depending on context -- here I use it to ensure that times are always normalized to an equal length of digits, so that the relative comparison operators work correctly -- but padding the minutes is almost always the expected thing.
"I already searched for this issue":**
Edition: (1st or 2nd)
Book Title: Get Started
Chapter: Appendix B: Practice, Practice, Practice
Section Title: Suggested Solution Comparisons (Pillar 3)
Question:
Should this section of the solution:
let meetingStart =
${ meetingStartHour.padStart(2,"0") }:${ meetingStartMinutes.padStart(2,"0") }; let meetingEnd =
${ String(meetingEndHour).padStart(2,"0") }:${ String(meetingEndMinutes).padStart(2,"0") };
`instead be
let meetingStart =
${ meetingStartHour.padStart(2,"0") }:${ meetingStartMinutes }; let meetingEnd =
${ String(meetingEndHour).padStart(2, "0") }:${ String(meetingEndMinutes) };
because even if the meetingEndMinutes was a single digit you wouldn't want to pad with a leading zero?