Etch-a-Sketch making the grid darker

Hi, I’m doing the etch-a-sketch project and managed to make the black and random color parts but I’m have trouble with the darkening one

My code

I put the hover color with hsl and set the lightnening as a variable, then everytime it hover over a cell it gets 10% darker. My problem is that since the variable receives the darker lightnening the color just becomes black when I hover. I understand it’s working exactly like I coded, I’m looking for a way to make it work like the project says(each block getting slightly darker once hovered).

Thanks

I had the same issue.

Here is an outline of what I did:
* gave each div in my grid a unique id, i.e. cell0, cell1, etc
• used an array instead of a single variable for lightening.
• gave the array one element for each div in my grid, so the number of array elements was equal to the number of divs in my array.
• populated the array with my initial lightening value.
• decremented only the array element corresponding to the grid div on which the mouseover occurred.

In your code, it looks like you might need to pass the relevant lightening value to your shading() function.

I’d be happy to share the relevant parts of my code, just let me know.

Good luck!

I think that the problem lies in the logic of the event handler,
when you call lightness -= 5 I think you’re permanently removing 5 from lightness —which was declared outside the event—, and the remainder of that operation is assigned to the string you pass to the DOM.

Let us know what you find out!