{"id":81671,"student_id":3232,"content":"// 將每題做成一個功能,在這邊執行\n// 這樣就可以保留你所寫過的所有程式,又不影響操作囉~\n\nf4();\n\n//---------------------------------------------------\nfunction test1() {\n console.log(10+20+30); //數值+數值\n console.log('10'+'20'+'30'); //字串+字串\n console.log(10+'20'); //數值+字串\n}\n//---------------------------------------------------\nfunction test2() {\n alert(\"提示文字\");\n}\n//---------------------------------------------------\nfunction test3() {\n var a = prompt(\"提示文字\");\n console.log(a);\n console.log(Number(a)); //將字串轉數值,但文字的內容會出錯(NaN=Not a Number)\n}\n//---------------------------------------------------\nfunction a1() {\n var a1 = prompt(\"輸入名字\");\n alert(\"hello\"+\" \"+a1);\n}\n//---------------------------------------------------\nfunction a2() {\n var num1 = Number(prompt(\"輸入數字\"));\n var num2 = Number(prompt(\"輸入數字\"));\n var num3 = Number(prompt(\"輸入數字\"));\n alert(num1+num2+num3);\n}\n//---------------------------------------------------\nfunction a3() {\n var apple = Number(prompt(\"蘋果顆數\"));\n var people = Number(prompt(\"人數\"));\n var a = apple/people;\n a = Math.floor(a);\n alert(\"每人分到\"+ a+\"個,剩下\"+apple%people+\"個\");\n}\n//---------------------------------------------------\nfunction a4() {\n var second = Number(prompt(\"輸入秒數\"));\n var hour = second/60/60;\n hour = Math.floor(hour);\n var minute = second/60%60;\n minute = Math.floor(minute);\n second = second%60;\n alert(hour+\"小時\"+minute+\"分鐘\"+second+\"秒\");\n}\n//---------------------------------------------------\nfunction a5() {\n var n = Number(prompt(\"輸入數字\"));\n var t = n/10;\n t = Math.floor(t);\n var o = n%10;\n alert(t + \", \" + o);\n\n}\n//---------------------------------------------------\nfunction a6() {\n var n = Number(prompt(\"輸入大於十的數字\"));\n var a = n/10;\n a = Math.floor(a);\n a = a%10;\n alert(a);\n}\n//---------------------------------------------------\nfunction a7() {\n var a = prompt(\"輸入數字\");\n var b = prompt(\"輸入數字\");\n var tmp;\n tmp = a;\n a = b;\n b = tmp;\n alert(a + \", \" + b);\n}\n//---------------------------------------------------\nfunction b1() {\n var n = Number(prompt(\"輸入數字\"));\n if (n%2 == 0) {\n alert(n + \"是偶數\");\n } else {\n alert(n + \"是奇數\");\n }\n}\n//---------------------------------------------------\nfunction b2() {\n var num1 = Number(prompt(\"輸入數字\"));\n var num2 = Number(prompt(\"輸入數字\"));\n var num3 = Number(prompt(\"輸入數字\"));\n var num4 = Number(prompt(\"輸入數字\"));\n var num5 = Number(prompt(\"輸入數字\"));\n var tmp = num1;\n if (tmp \u003e num2) {\n tmp = num2\n }\n if (tmp \u003e num3) {\n tmp = num3\n }\n if (tmp \u003e num4) {\n tmp = num4\n }\n if (tmp \u003e num5) {\n tmp = num5\n }\n alert(tmp)\n}\n//---------------------------------------------------\nfunction b3() {\n var num1 = prompt(\"輸入數字\");\n var num2 = prompt(\"輸入數字\");\n var num3 = prompt(\"輸入數字\");\n var tmp;\n if (num1 \u003e num2) {\n tmp = num2;\n num2 = num1;\n num1 = tmp;\n }\n if (num2 \u003e num3) {\n tmp = num3;\n num3 = num2;\n num2 = tmp;\n }\n if (num1 \u003e num2) {\n tmp = num2;\n num2 = num1;\n num1 = tmp;\n }\n if (num2 \u003e num3) {\n tmp = num3;\n num3 = num2;\n num2 = tmp;\n }\n alert(num1 + \" \" + num2 + \" \" + num3)\n}\n//---------------------------------------------------\nfunction c1() {\n var high = Number(prompt(\"輸入身高\"));\n high = high/100;\n var weight = Number(prompt(\"輸入體重\"));\n var BMI = weight/high/high;\n BMI = Math.round(BMI*100);\n BMI = BMI/100;\n var a;\n if (BMI \u003c 18.5) {\n a = \"過輕\";\n } else if (BMI \u003e= 18.5 \u0026\u0026 BMI \u003c 24) {\n a = \"正常\";\n } else if (BMI \u003e= 24) {\n a = \"過重\"\n }\n\n\n alert(\"您的BMI:\" + BMI + \",為\" + a);\n}\n//---------------------------------------------------\nfunction d0() {\n for (var i = 1; i \u003c 11; i++) {\n console.log(i);\n }\n}\n//---------------------------------------------------\nfunction d1() {\n for (var i = 10; i \u003e 0; i--) {\n console.log(i);\n }\n}\n//---------------------------------------------------\nfunction d2() {\n var a = 20;\n for (var i = 10; i \u003c a+1; i++) {\n console.log(i);\n }\n}\n//---------------------------------------------------\nfunction d3() {\n var a = 5;\n for (var i = 8; i \u003e a-1; i -= 1) {\n console.log(i);\n }\n}\n//---------------------------------------------------\nfunction d4(){\n var a = [1, 2, 3, 4];\n var b = 0;\n for(var i = 1; i\u003c6; i++){\n b = 0;\n for(var j = 0; j\u003ca.length; j++){\n if(i == a[j]){\n b = 1;\n }\n }\n if(b == 0){\n console.log(i+'沒有');\n }\n }\n \n}\n//---------------------------------------------------\nfunction d5(){\n var a = 4;\n var b = \"1\";\n for(var i = 2; i \u003c a + 1; i++){\n b += i; \n }\n console.log(b);\n}\n//---------------------------------------------------\nfunction d6(){\n var a = 5;\n var b = \"1\";\n for(var i = 2; i \u003c a + 2; i++){\n console.log(b);\n b += i;\n }\n}\n//---------------------------------------------------\nfunction e1(){\n var n = 1;\n var a = 50;\n while(n * n \u003c a){\n console.log(n*n);\n n++;\n }\n}\n//---------------------------------------------------\nfunction f1(){\n var a = \"kodingschool\";\n for(var i = 0; i \u003c 6; i++){\n console.log(a[i]);\n }\n}\n//---------------------------------------------------\nfunction f2(){\n var a = \"kodingschool\";\n for(var i = 11; i \u003e 5; i--){\n console.log(a[i]);\n }\n}\n//---------------------------------------------------\nfunction f3(){\n var a = \"kodingschool\";\n for(var i = 0; i \u003c 12; i+=2){\n console.log(a[i]);\n }\n}\n//---------------------------------------------------\nfunction f4(){\n var s = '蘋果,橘子,香蕉,芭樂,葡萄,柳橙,西瓜';\n var arr = s.split(\",\");\n console.log(arr[Math.floor(Math.random()*7)]);\n}\n//---------------------------------------------------\n\n//---------------------------------------------------","created_at":"2019-07-20T11:14:15.393+08:00","updated_at":"2019-10-26T11:52:12.973+08:00","name":"測驗題 副本","language":"javascript","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/81671/fd1ac05835b665cf0d7e3c5532c7c2d7.jpg"},"parent_id":73508,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":68,"hashid":"jzmsw5zk","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1392507,"file_name":"earth.png","project_id":81671,"asset_id":107440,"created_at":"2019-07-20T11:14:15.398+08:00","updated_at":"2019-07-20T11:14:15.398+08:00"},{"id":1392508,"file_name":"space_bg.jpg","project_id":81671,"asset_id":107441,"created_at":"2019-07-20T11:14:15.399+08:00","updated_at":"2019-07-20T11:14:15.399+08:00"},{"id":1392509,"file_name":"koding.png","project_id":81671,"asset_id":107442,"created_at":"2019-07-20T11:14:15.400+08:00","updated_at":"2019-07-20T11:14:15.400+08:00"},{"id":1392510,"file_name":"Gymnopedie_No_1.mp3","project_id":81671,"asset_id":107443,"created_at":"2019-07-20T11:14:15.401+08:00","updated_at":"2019-07-20T11:14:15.401+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦