This is my Javascript code:
function getRandomCard(){
randomCard = Math.floor(Math.random()*13)+1
if (randomCard === 1){
return 11
}
else if (11 <= randomCard <= 13){
return 10
}
else{
return randomCard
}
}
console.log(getRandomCard())
I have linked it to an HTML file with a button to call this function on getting clicked. Every time it is, it only returns 10 or 11. What could be wrong with my code?
Not sure maybe your if condition is wrong..
function getRandomCard(){
randomCard = Math.floor(Math.random()*13)+1
if (randomCard === 1){
return 11
}
else if (11 <= randomCard && randomCard <= 13){
return 10
}
else{
return randomCard
}
}
console.log(getRandomCard())