I want to create a simple function that plays a specific sound file based on the argument you pass to it. I understand that I need to use something like this:
const audio = new Audio("freejazz.wav");
audio.play()
But what would you do if you had 3 different sound files? A, I supposed to have const audio1 = new Audio("paidjazz.wave"); etc?
I will be calling these files regularly, so will the 'new' keyword keep calling fresh instances, leading to a memory leak?
How can I create a function that plays the sound if I use something like play("MySoundName")?