谢谢你回答我原来的问题,我只是编辑这篇文章的原因是因为我的第二个问题关于这段代码是因为该网站不会让我提出很多问题。我的问题是为什么isnt makesjump1随机为真或假?它似乎总是成真。请帮助@Yhlas和@codeConcussion为什么不在此代码中的随机化工作?
var isjumping1 = true;
while(isjumping1) {
var makesjump1 = Math.random()
if(makesjump1 => .51) {
makesjump1 = true }
else if(makesjump1 <= .50) {
makesjump1 = false }
var jump1 = prompt("Do you choose to JUMP, or let the fairies help you FLY").toUpperCase()
switch(jump1) {
case 'JUMP':
if(makesjump1 = true) {
console.log("You made the jump on your own, so the fairies reward you with a steel sword(9 DMG)")
damage = 9;
weapon = 'steel sword(9 DMG)'; }
else if(makesjump1 = false) {
console.log("You attempt the jump but miss it, and are hanging on by a thread")
console.log("The fairies rescue you, but you got scratched up, doing 3 damge to you.")
health = health - 3; }
isjumping1 = false;
break;
case 'FLY':
console.log("The fairies help you over the pit")
isjumping1 = false;
break;
default:
alert("That was not a choice!")
break; }
}
发布实际代码时,应该为语言的内容添加标签。它影响语法着色并帮助其他人找到问题。 – crashmstr
对不起,我将添加标签,现在我忘了 –