1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <title>Document</title> 7 8 <script> 9 /* 10 if switch 11 prompt 給一個彈窗,可以輸入,返回的結果就是使用者在視窗上輸入的值,以string型別返回 12 如果想轉換成int型別,可以用Number.parseInt(變數名) 13 */ 14 15 /* 16 var month = prompt("請輸入月份") 17 var month = Number.parseInt(month) 18 if(month == 12 || month == 1 || month == 2){ 19 console.log("冬季") 20 }else if(month == 3 || month == 4 || month == 5){ 21 console.log("春季") 22 }else if(month == 6 || month == 7 || month == 8){ 23 console.log("夏季") 24 }else if(month == 9 || month == 10 || month == 11){ 25 console.log("秋季") 26 }else{ 27 console.log("錯誤") 28 } 29 */ 30 31 /* 32 1 非空字串,會判斷為true 33 2 非空物件,會判斷為true 34 3 非0 number,會判斷為true 35 */ 36 if('false'){ 37 console.log(true) 38 }else{ 39 console.log(false) 40 } 41 42 43 </script> 44 45 </head> 46 <body> 47 48 </body> 49 </html>