Associating audio with an ID allows you to have multiple instances of audio on the same page, and reference them individually by their unique ID. This can be useful if you want to control multiple audio sources at different times, for example, to pause, resume, or stop an individual audio source, or to check if it has finished playing or not. By giving each audio source a unique ID, you can easily reference it in your JavaScript code and perform actions on it as needed.
Need to make sounds cleaner and able to mute when switch away from a page. Some ideas from chatGPT
When you create an HTMLAudioElement, you can assign it an ID to easily reference it later on, like this:
With an ID, you can easily control the audio with JavaScript, for example: