@ioangheraszim
Posted
Dear Weronika,
Congratulations on successfully completing this challenge. I have carefully reviewed your code and would like to provide some insights and suggestions.
- To retrieve data from the data.json file, you can utilize JavaScript's fetch function. Ensure that you assign a unique ID to each element that needs to be populated with data, such as the score, category, description, and individual icons and scores.
An Example of this would be:
fetch('data.json')
.then(response => response.json())
.then(data => {
const resultScore = document.getElementById('result-score');
const resultCategory = document.getElementById('result-category');
const resultDescription = document.getElementById('result-description');
// Populate the result section
resultScore.textContent = data[0].score;
resultCategory.textContent = data[0].category;
resultDescription.textContent = `You scored higher than ${data[0].score}% of the people who have taken these tests.`;
}).catch(error => {
console.error('Error:', error);
});
- In terms of CSS, I recommend using the min-height: 100vh property to position your component in the middle of the page vertically. This ensures that the component occupies at least the full height of the viewport, providing a visually pleasing and balanced layout. Additionally, for the button, consider adding the cursor: pointer property to enhance user experience by indicating that the button is clickable.
I hope you find these suggestions helpful in further improving your code.
Best regards, Ioan
@WerSzpe
Posted
@ioangheraszim Thank you for advice!