I've been experimenting with JavaScript to create a blackjack game, but I'm having trouble getting my code to work properly. My goal is for the getRandomCard() function to generate numbers between 1 and 13. Specifically, I want it to return 11 when the random number is 1, and 10 when the random number is 11, 12, or 13.
However, when I run my code, all it returns is the number 11. I can't figure out what's going wrong. Here's the snippet of code I wrote:
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())
If you could provide some guidance on where I may have gone astray, I would greatly appreciate it. Thank you!