Audio in JS not working
neodymium (30)

I'm trying to play audio by doing this:

var audio = new Audio("sound.mp3");;

I am getting a little click on my speakers but the sound is not playing. Is there another way of doing this?

You are viewing a single comment. View All
ArchieMaclean (820)

do you have a link to a repl?

locness3 (13)

@neodymium Make sure your browser doesn't block audio autoplay, I allowed it and it worked for me. Also check the console.

locness3 (13)

@neodymium BTW commenting in CSS doesn't work with // like you did somewhere