Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Launch Countdown Timer

Kaio 460

@kaiohnr

Desktop design screenshot for the Launch countdown timer coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
3intermediate
View challenge

Design comparison


SolutionDesign

Solution retrospective


I'd like to know what would be a better way to insert a zero in front of the number without have to repete those lines of code?

Community feedback

@ejim11

Posted

if you are using js, you can make use of paddingStart(0,2). meaning 0 is the number in front if the digit is from 0-9.

Marked as helpful

1

Kaio 460

@kaiohnr

Posted

@ejim11 Thanks!

0

@ejim11

Posted

const timeLeftNow = { day: String(Math.trunc(totalSeconds / (60 * 60 * 24))).padStart(2, 0), hour: String(Math.trunc((totalSeconds / (60 * 60)) % 24)).padStart(2, 0), minute: String(Math.trunc((totalSeconds / 60) % 60)).padStart(2, 0), second: String(Math.trunc(totalSeconds % 60)).padStart(2, 0), };

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord