Assessment wanted for Image gallery//

Can somebody pls assess the code.

Thank you

Hi @brusli

Congratulations! Everything works correctly :medal_sports:

Just two simplifications (matter of taste):

  • When looping over arrays we can use the more modern and shorter for...of or forEach loops
  • You don’t need setAttribute() to assign a value to src. Direct assignment is fine.
  • When using arrow functions we can leave out the curly braces. This would be ok:
    newImage.addEventListener('click', e => displayedImage.src = e.target.src);
    

I hope that helps!

Happy coding,
Michael

3 Likes