From f7dc926c92a5bc4b175e878202249c186b1add70 Mon Sep 17 00:00:00 2001 From: ArZarLordOfMango <96249677+ArZarLordOfMango@users.noreply.github.com> Date: Fri, 28 Jul 2023 19:03:24 +0200 Subject: [PATCH] Update script.js --- script.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/script.js b/script.js index 7e94f1b..171c91d 100644 --- a/script.js +++ b/script.js @@ -1,4 +1,5 @@ -function playSound() { - var audioElement = document.getElementById("sound"); - audioElement.play(); -} \ No newline at end of file +function playSound(button) { + const soundFile = button.dataset.sound; + const audio = new Audio(soundFile); + audio.play(); +}