Opinions wanted for 'Gallery Start'

Hello everybody,
submitting the code for ‘Gallery Start’ skill test. I’ll appreciate any opinions on it.
Thank you kindly.

Hi @texas-triumph

Nice work! Your code appears correct. I have two optimizations:

  • Most of the time we can use dot notation instead of getAttribute() and setAttribute() (Also note I have removed the template string):
    /* Before */
    displayedImage.setAttribute('src', `${e.target.getAttribute('src')}`)
    /* After */
    displayedImage.src = e.target.src;
  • For the “darken/lighten” function it seems easier to use a class name in the condition. It would separate the logic from the styling. Changing the button text would also make sense.

On a general note:
When using GitHub for these bigger exercises, it would be useful to put the whole code (HTML, CSS, JS) into the folder and activate “GitHub Pages” for the repo. This will deploy your project on a separate GitHub domain and we can see your GitHub code in action. It’s a really cool feature: https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site

I hope that helps,

Hello Michael,
Apologies for my late reaction to your review notes on the Gallery Start.
Appreciate it.
It was amazing to realize that that simple dot notation (’.src’) simplified those lines to such an extent. Very nice hint and a good demonstration that I completely omitted it after the course. Very valuable hint.
As for the files on the github, I’ll look into that, I’m still feeling unconfident pushing all those things via vs code’s powershell, and you’re right, I was feeling a bit uneasy pushing the only main.js without index and syles. not the best way to post and ask for opinions. thanks for the note.

1 Like