[英]Trying to figure out how to stop a CSS animation on my hamburger menu after the sidebar opens on a site I am working on
[英]I am trying to figure out how to make my functions run one after another… but it is not working
我正在嘗試使用JavaScript創建一個非常簡單的基於文本的冒險游戲。 我是個新手,我覺得與某些函數,變量和if-else語句一起使用會很棒。 我寫了一些代碼來提示屏幕詢問年齡並給出結果。
confirm("Ready to play?");
var age = prompt("How old are you?");
if (age >= 18) {
document.write(" ");
} else {
document.write("You're less than 18? You better just stay home.");
}
document.write("<button> Sounds like you're ready.</button>");
var gender = prompt("Male","Female");
if(gender = "Male") {
document.write("Sounds good!");
} else if(gender = "Female") {
document.write("Sounds good!");
} else if {
document.write("You're a damn liar");
};
};
如果我只運行代碼的前半部分,那么一切都會正常運行。 但是,如果我嘗試在原始代碼的旁邊運行性別提示,它將不會運行。 有什么建議么?
此代碼應工作:
confirm("Ready to play?");
var age = prompt("How old are you?");
if (age >= 18) {
document.write(" ");
} else {
document.write("You're less than 18? You better just stay home.");
}
document.write("<button> Sounds like you're ready.</button>");
var gender = prompt("Are you Male or Female?");
if(gender == "Male") {
document.write("Sounds good!");
} else if(gender == "Female") {
document.write("Sounds good!");
} else {
document.write("You lie...");
}
基本上,您需要將=
替換=
==
或===
。 而且prompt()
只接受一個參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.