Time tracking dashboard

Solution retrospective
Hello guys !
This is my third junior challenge :)
I'm not very sure of my function to make the request and get the data from the JSON.
Also If anyone have any feedback on my JS about make things simplier or best practices it would be a pleasure to hear from you !
Thanks :)
Please log in to post a comment
Log in with GitHubCommunity feedback
- @JustShuaib
Hi there! I just wanted to point out a few things. While fetching the data from the
json
file, always include a way to catch errors incase the request fails to be successful.You had
document.addEventListener("DOMContentLoaded", () => { // function async to get data from the json file async function loadObjJson() { const response = await fetch("./assets/js/data.json"); const data = await response.json(); console.log(data);
Declare a function in a separate block then call the function inside the
DOMContentLoaded
event listener,instead of including the function block inside the event listener. Also, always removeconsole logs
from your code when you're doneAlso for your titles, instead of selecting them individually,you could give all the headings the same class and
querySelectorAll
all the headings then loop through the data to display each in the respective title.Happy coding!✌️😊
Marked as helpful
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