Front End Development Libraries Projects - Build a Drum Machine

Tell us what’s happening:
Describe your issue in detail here.

Its on-off switch on drum machine
it should only play when switch is on but its not working

Your code so far

$(‘#on-off’).click (function ()
{
if ($(this).is(‘:checked’)) // to see whether switch is on or off
{
console.log($(‘#on-off’).is(‘:checked’))
$(‘button’).click(function() { // mouse click event: play sound when mouse clicked
const idChar = $(this).text()
$(‘#display’).text(soundText[idChar[0]])
$(#${idChar}).get(0).play()
})

$(document).keydown(function(e) {         // keydown event: play sound when key pressed
  const key = String.fromCharCode(e.which)
  $('#display').text(soundText[key])
  $(`#${key}`).get(0).play()
})

$('#volume').change(function() {             // Show volume when it is changed
  const val = $('#volume').val()
  $('#display').text(`Volume: ${val}`)
  currentVol = val
})

}else {
console.log($(‘#on-off’).is(‘:checked’))
$(‘#display’).text(‘’)
$(‘#volume’).prop(‘disabled’, true)
}
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Front End Development Libraries Projects - Build a Drum Machine

Link to the challenge:

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