const sounds = [
'Jason',
'lil Jon',
'mario',
'TwoClock',
'beep boppy',
'Dixon Cider',
'Baldy',
'PK Fire',
'look Eye',
'Show up'
];
sounds.forEach((sound) => {
const btn = document.createElement('button');
btn.classList.add('btn'); // sound button formula
btn.innerText = sound;
btn.addEventListener('click', () => {
// stopSongs();
document.getElementById(sound).play();
});
document.getElementById('buttons').appendChild(btn);
});
//#19 stops sound from playing when you click on another button
//adding a filter for our search
<h1>Dr s</h1>
<h2>Sound board</h2>
<!--Filter-->
I tried looking up and could not find a way to add a filter search for buttons. I know it should be a function just struggling on how to set it up.
This might be your solution, you forgot to add }) to the end of one of your functions. Your code should work now!
const sounds=[
'Jason',
'lil Jon',
'mario',
'TwoClock',
'beep boppy',
'Dixon Cider',
'Baldy',
'PK Fire',
'look Eye',
'Show up'
];
sounds.forEach((sound) => {
const btn = document.createElement('button');
btn.classList.add('btn');
btn.innerText = sound;
btn.addEventListener('click', () =>{
document.getElementById('buttons').appendChild(btn);
}); // <= You forgot this
});
<div id="buttons">
</div>