I am creating a game that is supposed to help me and learn somethings, but I have run into a problem which I can figure out. The problem is that I have created a select tag and they need to select the speed they want, but when they click it, the selection does not work. It returns 50 once then it returns 500 I don't not know why, I have aa excerpt of my game below and under that is the full code, Please check them both out thank you.
Excerpt from the Game:
$(document).ready(function() {
let NewSpeed = $("#Selection option:selected").val();
// console.log(NewSpeed)
$("input").click(function() {
let TimeSpeed;
console.log("This Part Excuts")
switch (NewSpeed) {
case (NewSpeed = 100):
TimeSpeed = 100;
break;
case (NewSpeed = 300):
TimeSpeed = 300;
break;
case (NewSpeed = 500):
TimeSpeed = 500;
break;
default:
TimeSpeed = 50;
break;
}
console.log(TimeSpeed)
})
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="#">
<select id="Selection">
<option value="50">50</option>
<option value="100">100</option>
<option value="300">300</option>
<option value="500">500</option>
</select>
</form>
<input type="button" name="btn" id="btn" value="Click Me" />
</body>
</html>
Full Version: https://codepen.io/Giannilmgc/pen/JjrgZdr