Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
renly261 authored Mar 15, 2021
0 parents commit 8091f4f
Show file tree
Hide file tree
Showing 20 changed files with 635 additions and 0 deletions.
Binary file added 20210315 JS/上課/d1732767.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions 20210315 JS/上課/while.html
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>
56 changes: 56 additions & 0 deletions 20210315 JS/上課/問答題.html
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>
23 changes: 23 additions & 0 deletions 20210315 JS/上課/星星1.html
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>
31 changes: 31 additions & 0 deletions 20210315 JS/上課/星星2.html
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>
28 changes: 28 additions & 0 deletions 20210315 JS/上課/球.html
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>
21 changes: 21 additions & 0 deletions 20210315 JS/上課/變數.html
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>
27 changes: 27 additions & 0 deletions 20210315 JS/上課/迴圈.html
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>
45 changes: 45 additions & 0 deletions 20210315 JS/上課/迴圈2.html
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>
16 changes: 16 additions & 0 deletions 20210315 JS/上課/顏色星星.html
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>
27 changes: 27 additions & 0 deletions 20210315 JS/上課/顏色表格.html
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>
28 changes: 28 additions & 0 deletions 20210315 JS/我/while.html
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>
40 changes: 40 additions & 0 deletions 20210315 JS/我/星星塔.html
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>
Loading

0 comments on commit 8091f4f

Please sign in to comment.