謝謝你回答我原來的問題,我只是編輯這篇文章的原因是因爲我的第二個問題關於這段代碼是因爲該網站不會讓我提出很多問題。我的問題是爲什麼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
對不起,我將添加標籤,現在我忘了 –