This is a solution to the Expenses chart component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the bar chart and hover over the individual bars to see the correct amounts for each day
- See the current day’s bar highlighted in a different colour to the other bars
- View the optimal layout for the content depending on their device’s screen size
- See hover states for all interactive elements on the page
- Bonus: Use the JSON data file provided to dynamically size the bars on the chart
- Semantic HTML5
- CSS custom properties
- Flexbox
- Mobile-first workflow
- Vanilla JavaScript
I learned how to fetch data from json files and process them. I also used promises + async await for the first time in practise.
async function fetchData() {
const response = await fetch('./data.json');
const data = await response.json();
return data;
}
fetchData()
.then(data => setData(data))
.catch(error => {
console.error(error);
});In the future I want to work on async JavaScript.
- JSON fetch solution - This helped me when I was trying to import JSON file into JS. I really liked this pattern and will use it going forward.
- Website - Mateusz Hladky
- Frontend Mentor - @matibox
- Twitter - @m4t1box
