Why won't my drum machine pass the tests?

It plays the sound when the buttons are clicked and when the keys are pressed. The audio element is a child of the Button element and it appears to work when clicked but tests 5-7 are showing a no pass for me.
This is the link to my codepen project.

That’s because in click you’re calling setState which triggers rerender before test manages to play the clicked audio element.

And setState doesn’t return promise, so async/await won’t do anything (when people say that setState is asynchronous, that’s not what they mean).

For reference: https://codepen.io/jenovs/pen/QPjKaX

Thanks so much, I didn’t know that about the setState, good to know.

Can I ask what the {" "} next to the {obj.id} and inside the audio do?

a {" "} forces a space to be rendered between elements, since whitespace is otherwise ignored by React. It’s often added automatically by VSCode when pasting code into the editor (or IntelliJ, I forget which).

1 Like

Thank you, that makes sense

Can we do this project using jQuery?