第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么我的 if-else 語(yǔ)句不能使用 OR ( | | ) 來(lái)工作?

為什么我的 if-else 語(yǔ)句不能使用 OR ( | | ) 來(lái)工作?

當(dāng)我運(yùn)行該程序時(shí),控制臺(tái)給出一個(gè)錯(cuò)誤,指出“星期日”(和“星期六”,基于用戶輸入)不存在。我在 if 語(yǔ)句中嘗試了多種帶括號(hào)的組合,但沒(méi)有任何效果。var day = prompt("Enter a day of the week.");console.log("Day is: " + day);//if user input is equal to Sunday OR user input is equal to Saturday,if (getText(day) == "Sunday" || getText(day) == "Saturday") {  console.log("It's the weekend!");} else {  console.log("Can't wait for the weekend to get here.");}
查看完整描述

2 回答

?
慕婉清6462132

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊

您應(yīng)該刪除它getText,它將正常工作:


var day = prompt('Enter a day of the week.');

console.log('Day is: ' + day);

if (day == 'Sunday' || day == 'Saturday') {

  console.log("It's the weekend!");

} else {

  console.log("Can't wait for the weekend to get here.");

}


查看完整回答
反對(duì) 回復(fù) 2023-11-02
?
30秒到達(dá)戰(zhàn)場(chǎng)

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個(gè)贊

如果用戶單擊“確定”或單擊“取消”,該prompt()函數(shù)始終返回 a 。在您的情況下,只要您輸入一些內(nèi)容并單擊“確定”,就會(huì)出現(xiàn)一個(gè)字符串,可能是或。stringnullday"Sunday""Saturday"


但是,如果您希望將大寫(xiě)字母和小寫(xiě)字母視為相同,例如"sunday"相當(dāng)于"Sunday",則應(yīng)使用toLowerCase()ortoUpperCase()方法來(lái)確保兩個(gè)字符串要么全部小寫(xiě),要么全部大寫(xiě)。像下面這樣:


var day = prompt("Enter a day of the week.");

console.log("Day is: " + day);

//if user input is equal to Sunday OR user input is equal to Saturday,

if (day.toLowerCase() == "sunday" || day.toLowerCase() == "saturday") {

  console.log("It's the weekend!");

} else {

  console.log("Can't wait for the weekend to get here.");

}


查看完整回答
反對(duì) 回復(fù) 2023-11-02
  • 2 回答
  • 0 關(guān)注
  • 159 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)