Drum Machine working but does not pass tests 5 & 6

Hi,

I have been working on the Drum Machine project using just jQuery as I have been out of coding for a while and wanted to refresh what I had learnt before.

Everything is working as it should, however I am still failing tests 5 and 6 about playing the audio clip contained in its child audio element when clicked or the key is pressed.

The sounds do play, so I wondering if it is something to do with how I am getting jQuery to access the audio elements?

If anyone could have a look and shed some light on the situation I would be extremely grateful.

Thank you,
Stu

It is because you are using the Audio constructor. The tests expect the play method to be called on the audio element in the DOM.

Edit: Your switch is also looking for the wrong key codes. It should be the lowercase key codes, not uppercase.


As an aside. Both which and keyCode is technically deprecated. I would maybe suggest you look at using key instead.

1 Like

Ah yes, I thought it might have been the Audio constructor that was the problem, not sure why I didn’t just use the DOM in the first place.

I have changed the constructor and the key codes and now I am passing all the tests so thank you. I still have an issue with the button backgrounds remaining red when multiple keys are pressed simultaneously which I need to fix but that is less of a priority.

I did not realise which and keyCode are now basically defunct, thank you for pointing me to ‘key’. That was exactly what I was looking for in the first place but I somehow missed it in my search. I shall change it to ‘key’ when I get the chance.

Thank you for taking the time to help me.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.