I don't understand why my code is not working. I am teaching myself JavaScript and here's the code I used. It is for a version of the blackjack game. I want the getRandomCard() function to return a number between 1 and 13. However, I want it to return 11 when the randomNumber is 1 and for it to return 10 when the randomNumbers are 11, 12 and 13.
Why isn't it working?
function getRandomCard() {
let randomNumber = Math.floor(Math.random() *13) + 1
if (randomNumber = 1) {
return 11
} else if (randomNumber = 11, 12, 13 ) {
return 10
} else {
return randomNumber
}
}
console.log(getRandomCard())
Here is what I did. But when I run it, all it returns is the number 11.
Your help would be appreciated.