-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8091f4f
Showing
20 changed files
with
635 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
let input = '' | ||
// while (input != 'end') { | ||
// input = prompt('輸入 end 結束') | ||
// } | ||
|
||
do { | ||
input = prompt('輸入 end 結束') | ||
} while (input != 'end') | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
let score = 100 | ||
|
||
let answer = prompt('1+1=?') | ||
if (answer === '2') { | ||
alert('恭喜答對') | ||
} else { | ||
alert('答錯') | ||
score -= 20 | ||
} | ||
|
||
answer = prompt('2+2=?') | ||
if (answer === '4') { | ||
alert('恭喜答對') | ||
} else { | ||
alert('答錯') | ||
score -= 20 | ||
} | ||
|
||
answer = prompt('4+4=?') | ||
if (answer === '8') { | ||
alert('恭喜答對') | ||
} else { | ||
alert('答錯') | ||
score -= 20 | ||
} | ||
|
||
answer = prompt('8+8=?') | ||
if (answer === '16') { | ||
alert('恭喜答對') | ||
} else { | ||
alert('答錯') | ||
score -= 20 | ||
} | ||
|
||
answer = prompt('16+16=?') | ||
if (answer === '32') { | ||
alert('恭喜答對') | ||
} else { | ||
alert('答錯') | ||
score -= 20 | ||
} | ||
|
||
alert(`遊戲結束,你得到了 ${score} 分`) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
let floor = prompt() | ||
|
||
// 跑每一層 | ||
for (let i=1;i<=floor;i++) { | ||
// 每一層的星星數與層數相同 | ||
for (let j=1;j<=i;j++) { | ||
document.write('★') | ||
} | ||
document.write('<br>') | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
let floor = prompt() | ||
|
||
// 每一層 | ||
for (let i=1;i<=floor;i++) { | ||
// 空心星星的數量是總層數減目前層數 | ||
for (let j=1;j<=floor-i;j++) { | ||
document.write('☆') | ||
} | ||
// 1 3 5 7 9 | ||
for (let j=1;j<=i*2-1;j++) { | ||
document.write('★') | ||
} | ||
// 空心星星的數量是總層數減目前層數 | ||
for (let j=1;j<=floor-i;j++) { | ||
document.write('☆') | ||
} | ||
document.write('<br>') | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
let height = 100 | ||
let distance = 0 | ||
|
||
for(let i=1;i<=10;i++) { | ||
// 總距離 + 落下距離 | ||
distance += height | ||
// 反彈高度變一半 | ||
height /= 2 | ||
// 總距離 + 反彈距離 | ||
distance += height | ||
} | ||
// 扣掉多算一次的反彈 | ||
distance -= height | ||
|
||
document.write(`高度: ${height} <br>距離: ${distance}`) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
let a = 'A' | ||
|
||
if (true) { | ||
let a = 1 | ||
console.log(a) // 1 | ||
} | ||
|
||
console.log(a) // A | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
// for(let i=0; i<10; i++) { | ||
// document.write(i) | ||
// } | ||
// let i 是區域變數,在外面 log 會出錯 | ||
// console.log(i) | ||
document.write('<table border="1">') | ||
for (let i=1;i<=9;i++) { | ||
document.write('<tr>') | ||
for(let j=1; j<=9; j++) { | ||
document.write(`<td>${i} * ${j} = ${i*j}</td>`) | ||
} | ||
document.write('</tr>') | ||
} | ||
document.write('</table>') | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
// for(let i=0;i<10;i++) { | ||
// if (i == 5) { | ||
// // continue 直接進入下次迴圈 | ||
// continue | ||
// } | ||
// document.write(i) | ||
// } | ||
// document.write("<br>") | ||
// for(let i=0;i<10;i++) { | ||
// if (i == 5) { | ||
// // break 直接中斷迴圈 | ||
// break | ||
// } | ||
// document.write(i) | ||
// } | ||
|
||
let count = 1 | ||
let num = 15 | ||
while (true) { | ||
let answer = prompt(`第 ${count} 次猜測`) | ||
if (answer == num) { | ||
break | ||
} | ||
else if (answer < num) { | ||
alert('太小') | ||
} | ||
else if (answer > num) { | ||
alert('太大') | ||
} | ||
count++ | ||
} | ||
document.write(`猜了 ${count} 次`) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
for(let i=0;i<=255;i+=5) { | ||
document.write(`<span style="color: rgb(${i}, 0, ${255-i})">★</span>`) | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script> | ||
// for(let i=0; i<10; i++) { | ||
// document.write(i) | ||
// } | ||
// let i 是區域變數,在外面 log 會出錯 | ||
// console.log(i) | ||
document.write('<table border="1">') | ||
for (let i=1;i<=9;i++) { | ||
document.write('<tr>') | ||
for(let j=1; j<=9; j++) { | ||
document.write(`<td style="background: rgb(${i*25}, 0, ${j*25})">${i} * ${j} = ${i*j}</td>`) | ||
} | ||
document.write('</tr>') | ||
} | ||
document.write('</table>') | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
let input = ""; | ||
while (input !== "end") { | ||
input = prompt("輸入 end 結束,不然煩死你"); | ||
} | ||
|
||
let input = ""; | ||
do { | ||
input = prompt("輸入 end 結束,不然煩死你"); | ||
} while (input !== "end") | ||
|
||
|
||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
|
||
<script> | ||
|
||
let floor = prompt() | ||
// 每一層 | ||
for (let i = 1; i <= floor; i++) { | ||
// 每一層星星數與層數相同 | ||
for (let j = 1; j <= i; j++) | ||
|
||
document.write('★') | ||
document.write('<br>') | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.