@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