Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

JavaScriptDOM

@DavidMachio

Desktop design screenshot for the Results summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


He practicado JavaScriptDOM, recuperando los elementos por id, también convertí el data.json en un data.js, y cree una función que pasándole cualquier data, devolverá la media de los valores.

Community feedback

Daniel 🛸 44,230

@danielmrz-dev

Posted

Hello David!

You did a very good job there!

I have just one very simple suggestion for improvement:

  • Since the button is a clickable element, it's nice to add cursor: pointer and the color shift effect.

This gives the user a visual indication that the element is clickable.

Other than that, you did a great job!

Marked as helpful

0

@DavidMachio

Posted

do it ... Thanks@danielmrz-dev

0

@buness

Posted

Hi @DavidMachio,

Great job!

Here are some suggestions for the JavaScript code:

  • Instead of fetching each category individually, consider fetching them all using a common class or a data attribute. For example:
HTML
<div class="date category1" data-category>...</div>
JS
const categories = document.querySelectorAll('[data-category]');
  • Modify the code to dynamically fill each category using a loop:
persona.forEach((p, i) => {
  const currCategory = categories[i];
  const icon = currCategory.querySelector('[data-icon]');
  icon.src = p.icon;
  icon.alt = p.category;
  currCategory.querySelector('[data-title]').textContent = p.category;
  currCategory.querySelector('[data-score]').textContent = p.score;
});
  • Ensure the number of categories in HTML matches the number in data.js, or dynamically create elements if needed:
HTML
<article class="dates" data-categories>...</article>
JS
const categoriesContainer = document.querySelector('[data-categories]');

persona.forEach((p) => {
  ...
  categoriesContainer.innerHTML += `
    <div class="date category1">
    <div class="datename">
      <img src="${p.icon}" alt="Icono ${p.category}" />
      <h3 class="textcategory1">${p.category}</h3>
    </div>
    <div class="value-date">
      <h3 class="value">${p.score}</h3>
      <h3 class="total">/ 100</h3>
    </div>
  </div>
});
  • When using a ternary operator to assign a value to a variable, consider assigning the result directly, like this:
JS
mensaje.textContent = valorMedio <= 90 ? 'You scored higher than 65% of the people who have taken these tests.' : 'You lose';

I hope it helps!

Great job overall!

0

Please log in to post a comment

Log in with GitHub
Discord logo

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