Konrad
@konradbaczykAll solutions
- Submitted 3 months ago
Time tracking dashboard - Fetch with JSON file
- HTML
- CSS
- JS
If u know please tell me how I can improve my code in this fragment:
fetch("./data.json") .then((res) => res.json()) .then((data) => ( (workCurrentTime.textContent = data[0].timeframes.daily.current), (workPreviousTime.textContent = data[0].timeframes.daily.previous), (playCurrentTime.textContent = data[1].timeframes.daily.current), (playPreviousTime.textContent = data[1].timeframes.daily.previous), (studyCurrentTime.textContent = data[2].timeframes.daily.current), (studyPreviousTime.textContent = data[2].timeframes.daily.previous), (exerciseCurrentTime.textContent = data[3].timeframes.daily.current), (exercisePreviousTime.textContent = data[3].timeframes.daily.previous), (socjalCurrentTime.textContent = data[4].timeframes.daily.current), (socjalPreviousTime.textContent = data[4].timeframes.daily.previous), (selfCareCurrentTime.textContent = data[5].timeframes.daily.current), (selfCarePreviousTime.textContent = data[5].timeframes.daily.previous) ) );
I didn't know how to use loop or other staff to minimize proces of looking for data.