【发布时间】:2021-12-20 10:20:45
【问题描述】:
我被困在二十一点任务上。我不知道如何让用户说出他们想要的多次hitMe Y/N。我的经销商面朝下。
let card = 0;
let total = 0;
let hitMe = true;
let dealer = 0;
//1st card
hitMe = prompt("Current total: " + total, "Take a card? Y/N");
// (hitMe == "Y"){hitMe = true;}
//se {hitMe = false;}
if(hitMe){
card = dealer = Math.ceil(11*Math.random()) + Math.ceil(11*Math.random());
total += card;
}
//final total
dealer = Math.ceil(11*Math.random()) + Math.ceil(11*Math.random()); //dealer always takes 2 cards
alert("Your hand is worth " + total + ". Dealer got " + dealer + ".");
【问题讨论】:
-
请澄清您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。