Hello I am creating a game similar to Simon. Where a user has to memorize a random color generated by the random color generator. When a button is clicked it is supposed to play a sound. I am able to play all the sounds when I click the buttons. I created a function that recognizes when the enter key is pressed to start the game. The game generates a random color with a corresponding sound and the user is supposed to click the same color. I am getting a ERROR NOT FOUND sounds/undefined.mp3 and also a DOM Exception: no supported source was found. It seems not to be able to find the right file. 
function nextSequence() {
level = level + 1;
randomNumber = Math.floor(Math.random * 4);
randomChosenColor = buttonColors[randomNumber];
gamePattern.push(randomChosenColor);
console.log(gamePattern);
//$("#" + randomChosenColor).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
animatePress(randomChosenColor);
playSound(randomChosenColor);
// animatePress(randomChosenColor);
}
$(".btn").click(function() {
var userChosenColor = $(this).attr("id");
userClickedPattern.push(userChosenColor);
console.log(userClickedPattern);
playSound(userChosenColor);
animatePress(userChosenColor);
});
function playSound(variable) {
$("#" + variable).ready(function() {
var audio = new Audio("sounds/" + variable + ".mp3");
audio.play();
});
}
$(document).on('keypress', function(e) {
if(e.which == 13) {
var h1header = document.getElementById("level-started").innerHTML = "Level " + level;
nextSequence();
started = true;
}
});
h1 {
text-align: center;
margin-bottom: 5%;
font-family: "Ubuntu";
font-size: 3rem;
}
body {
text-align: center;
}
.container {
width: 50%;
margin: auto;
}
.btn {
display: inline-block;
width: 200px;
height: 200px;
border: 10px solid black;
border-radius: 6%;
margin: 25px;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
.green {
background-color: green;
}
.yellow {
background-color: yellow;
}
.pressed {
box-shadow: 0 0 20px white;
background-color: grey;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Simon Game</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;900&family=Ubuntu:wght@300;400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 class="intro" id = "level-started">Press Enter Key to start </h1>
<div class="container">
<div class="row">
<div class="btn green" type="button" id="green">
</div>
<div class="btn red" type="button" id="red">
</div>
</div>
<div class="row">
<div class="btn yellow" type="button" id="yellow">
</div>
<div class="btn blue" type="button" id="blue">
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script type="text/javascript" src="index.js">
</script>
</body>
<footer>© Hello World </footer>
</html>