I have a code which I want to make play a certain sound when the spacebar is pressed;
The window.onload function is the major function that hosts everything within it (it is much bigger but for this, I am using just a small bit)
var mySound;
mySound = "pew.mp3";
window.onload = function () {
if (keysDown[spacebar] && reload > 30) {
shootBullet();
reload = 0;
mySound.play();
}
I get an error message from the console saying that
main.js:215 Uncaught TypeError: mySound.play is not a function
at run (main.js:215)
at loop (main.js:313)