Drum Machine - failing to pass Test #6

I have to point that currenty i’m doing it with jquery, not on react… and is not finished yet.
The sounds are playing when i click the buttons and when i press the keys, but tests are still failing

here’s the codepen link, https://codepen.io/guid0_py/pen/RejJpB?editors=1011
please help!

Hey there!

Good work making it this far!

So a couple things are going on here. I would guess the reason you are having issues is the test suite is trying to spam keys and your code is currently preventing that.

The solution:

  • Change your listeners to ‘keydown’ instead of keypress

  • Restart the clip each time the key is pressed via:

q.CurrentTime = 0;

Then run it and it works! Good luck!

It actually works just by changing to “keydown”.
I’m not sure why though… anyway, i’ll check on that.

Thanks a lot!

Yeh it will pass the tests, but I think makes the user experience worse since they can’t play the sound when or as quickly as they would like.

Also to save yourself some code you can omit the ending tag and make it self closing.

Good luck!

1 Like