How To Play an Audio file in JavaScript

Here is a quick and simple way to play an audio clip in JavaScript

const audio = new Audio('path/to/audio.mp3')

That is literally it.

You can set “” to where ever you need in your code so it gets triggered when needed.

Leave a Reply

Your email address will not be published. Required fields are marked *