Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
i was able to build according to the provided design
What challenges did you encounter, and how did you overcome them?i encountered problem with displaying the icons
What specific areas of your project would you like help with?Would appreciate help on the icon part, it is still not showing
Community feedback
- @rainofPosted 3 months ago
Great job! To resolve the issue of displaying different icons in each box, you should use the
map
function to iterate and display them. Here’s how you can do it:1.Create an Array of Image Paths:
const image_files = [ 'images/icon-1.svg', 'images/icon-2.svg', 'images/icon-3.svg', 'images/icon-4.svg' ];
2.Use
map
to Loop Through Each Topic:{topics.map((topic, index) => ( <div key={index} className={`sub_topic sub_topic-${index % image_files.length}`}> <div className="topic_name">{topic.name}</div> <p className="topic_description">{topic.description}</p> <img src={image_files[index % image_files.length]} alt={`icon-${index + 1}`} /> </div> ))}
This method ensures that each topic box displays a different icon by cycling through the images in the
image_files
array.0
Please log in to post a comment
Log in with GitHubJoin 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