Function 2: Unable to change color

I’m struggling with this challenge. I can’t seem to get the color of the rectangle to change from the default ‘black’ to ‘blue’. Also, am I using the .fillRect method correctly?
Thanks!
Leo

CodePen:
https://codepen.io/tonewheel/pen/ExKXJYO

Hello @Leo_S

you need to set the color first

ctx.fillStyle = color;
  ctx.fillRect(x, y, width, height);

cause your code make it draw the rectangle then set the color to blue

one more thing you do not need the last ctx.fill(); line use this one when you fill a path https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fill as fillrect draw the rectangle and fill it also

hope that help and have a nice day :slight_smile:

hope that help and have a nice day

That does the trick. Thanks a lot for your advice @justsomeone!

you very welcome @Leo_S