I just finished the drum machine project, but 2 of the test fields aren’t passing. However, both of them are displaying/playing audio as intended.
Test 5) says that when a .drum-pad is clicked it should trigger the audio. It does, and I definitely have the drum pad class as drum-pad. So I’m not sure why it’s failing.
Test 7) When a drum pad is triggered it should be displayed in #display. I definitely have unique names for each, and my display has an id of display, so again, not sure why it’s failing.
See attached Stackblitz link:
Sorry about the lengthy code… Just worked my way through it with stuff I remembered from the lessons.
Ahhhh I was just typing out another response seconds before you sent this.
Originally I was just consoling the Event logs… Then I starting consoling the variables I had (audio being one) and just realized that was null, which was throwing the error for trying to set currentTime.
ok, I have more to think about and fix, I’ll see where fixing this takes me.
I would suggest you use a button element for the buttons and don’t use a div for the text content that is on top of the click target.
If you remove the height of the button text div and click on the button div and on the text div you can see what is happening and that the same thing is not logged (because the event target is different). The element you click on should be the one with the event handler on it otherwise you are relying on event bubbling.
The test doesn’t actually click the buttons, it uses the elements and fires off events. It is basically “clicking” on the parent of the audio element and not your div text element.
Finally got it, removed the <div> tag from around text content that was on top the click target… After I did that, it started throwing the error which the FCC test script was throwing, which allowed me to then troubleshoot and get it right…
Took me a couple hours to jerk around with that synthetic event passed by onClick in order to get the information out of it that I needed.
But anyway! It works! I didn’t end up having to use a <button> to make it work.
I will 100% use button elements going forward. About to start the calculator now, so I’ll use them in it for sure! Just so I don’ t in the habit of making it out of a <div>