Assessment wanted for Events skill test

Hi,
I have taken up the assessment for “Test Your Skills: Events

I have tried out all the three problems and I wanted to check the solution:
Here are the CodePen links for my solutions:
Events 1: https://codepen.io/sindhu_ja/pen/NWxmMPb
Events 2: https://codepen.io/sindhu_ja/pen/BajExNK
Events 3: https://codepen.io/sindhu_ja/pen/rNxbvVd

Please check the solutions and let me know if I need to improve anything.

Thanks,
Sindhuja

Hi there @Sindhuja_G, and welcome to our community!

I’ve looked over your code, and the solutions you’ve provided all work perfectly — well done!

The only thing I noticed is that in events 2, you don’t need to write out the drawCircle() invocation 4 times; you could just call it once, after the if/else structure, like this:

canvas.onkeyup = function (ev) {
  if (ev.key == "w" || ev.key == "W") {
    y = y - 5;
  } else if (ev.key == "a" || ev.key == "A") {
    x = x - 5;
  } else if (ev.key == "d" || ev.key == "D") {
    x = x + 5;
  } else if (ev.key == "s" || ev.key == "S") {
    y = y + 5;
  }
  
  drawCircle(x, y, size);
};