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

Grid, Flexbox, JS, event listeners

P
Sam Hooker 410

@35degrees

Desktop design screenshot for the Time tracking dashboard coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

I'm proud that I came up with some solid data fetch syntax. I'm worried that I used the fetch syntax three times, one for each timeframe. I couldn't think of a way to reduce that to one fetch overall, which maybe can be done on "DOMLoaded" event. I also wasn't thrilled with how many lines of JS was required for each data point and I'm looking for ways to reduce all of those lines to keep it cleaner code.

Community feedback

P

@Hekimianz

Posted

Overall great job! Works as intended only issues i see are that you are repeating yourself many times throughout your code... The way i made it so that there was only one fetch was to create an object for each filter inside of the fetch like so:

const dailyData = {};
const weeklyData = {};
const monthlyData = {};
const fetchData = async () => {
  const response = await fetch("./data.json");
  if (!response.ok) {
    console.error("Could not fetch data!");
  }
  const data = await response.json();

  data.forEach((elem) => {
    dailyData[elem.title] = elem.timeframes.daily;
    weeklyData[elem.title] = elem.timeframes.weekly;
    monthlyData[elem.title] = elem.timeframes.monthly;
  });
} 

Im not saying its the correct way, just sharing the way i did it!😁

Marked as helpful

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