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

Responsive Timer Application built with JS, CSS & HTML

#sass/scss#jss

@anitha-nagadasarink

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


Kindly have look at the timer application. I will appreciate your valuable feedback.

Community feedback

Ivan 2,630

@isprutfromua

Posted

Hi there! Good job

I have some recommendations for you

  • you need to stretch the background with background-size: cover

  • in my opinion, the calcTimer function is redundant. Instead, you could use the following construction:

let diff = dateToLaunch - today;

function calculateTimer() {
.......
}

window.addEventListener('DOMContentLoaded', () => {
  const timerInterval = setInterval(calculateTimer, 1000);

  if (diff <= 0) {   
    clearInterval(timerInterval)
  }
});
  • In each interval tick you declare new variables with functions, this reduces performance
  const days = String(Math.trunc(time / (1000 * 60 * 60 * 24))).padStart(2, 0);
  const hours = String(Math.trunc((time / (1000 * 60 * 60)) % 24)).padStart(2, 0);
  const minutes = String(Math.trunc((time / 1000 / 60) % 60)).padStart(2, 0);
  const seconds = String(Math.trunc((time / 1000) % 60)).padStart(2, 0);

I would make calculations in separate constants. The date calculation would look like this:

const DAYS = 1000 * 60 * 60 * 24;
....
const left = {
  DAYS: null
  .....
}
...
calculateTimer() {
....
left.DAYS = Math.trunc(time / DAYS)

daysValue.textContent = days > 10 ? + days : `0${days}` ;   // use ternar because padStart is experimental
}

I hope my feedback will be useful.

Good luck and fun coding 🤝⌨️

Marked as helpful

0

@anitha-nagadasarink

Posted

@isprutfromua Thank you so much for your insightful feedback. I will update the solution.

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