function playSound(audioId) { // First, stop and reset any currently playing audio const allAudios = document.querySelectorAll('audio'); allAudios.forEach(audio => { audio.pause(); audio.currentTime = 0; }); // Play the requested audio var audio = document.getElementById(audioId); audio.play(); }