I am struggling with my random number generator that should generate numbers between 5 and 15. I am trying to change the position of the 'chest' div based on the number generated by the computer, but for some reason it is not working as expected. I have double-checked that the div is named 'chest', there is a CSS statement for 'left', and the function is indeed being called and generating a number.
Below is the code snippet:
var xChestPosition;
var yChestPosition;
function randomNumberForChest(firstNum, secondNum) {
xChestPosition = Math.floor(Math.random() * secondNum) + firstNum;
yChestPosition = Math.floor(Math.random() * secondNum) + firstNum;
alert(xChestPosition);
switch (xChestPosition) {
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
$('#chest').css('left','300');
break;
default:
// Handle other cases
break;
}
}