-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-3.html
94 lines (84 loc) · 2.34 KB
/
10-3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#rect {
position: relative;
width: 800px;
height: 600px;
background-color: #fff;
}
.ball {
position: absolute;
width: 40px;
height: 40px;
background-color: #f22;
border-radius: 50%;
color: #fff;
line-height: 40px;
text-align: center;
}
</style>
</head>
<body>
<!-- <input type="number" id='score' onchange="doCal()" onkeyup="doCal()" min='0' max="100"><br> -->
<div id="rect"></div>
<script>
const rect = document.querySelector('#rect')
let s
const food = ['apple', 'banana', 'coke']
food.pop()
rect.innerHTML += 'Pop : '
for (i=0;i<food.length; i++) {
rect.innerHTML += `${food[i]} `
}
rect.innerHTML += ' // 將最後一個值彈出'
rect.innerHTML +='<br>' //apple, banana
food.push('cake')
rect.innerHTML += 'Push cake : '
for (i=0;i<food.length; i++) {
rect.innerHTML += `${food[i]} `
}
rect.innerHTML += '// 從最後面推入一個值'
rect.innerHTML +='<br>' //apple, banana, cake
food.reverse()
rect.innerHTML += 'Reverse : '
for (i=0;i<food.length; i++) {
rect.innerHTML += `${food[i]} `
}
rect.innerHTML += '// 將順序反轉'
rect.innerHTML+='<br>' //cake, banana, apple
food.shift()
rect.innerHTML += 'Shift '
for(i=0;i<8;i++){
rect.innerHTML += ' '
}
rect.innerHTML += ': '
for (i=0;i<food.length; i++) {
rect.innerHTML += `${food[i]} `
}
for(i=0;i<9;i++){
rect.innerHTML += ' '
}
rect.innerHTML += '// 從最前面一個值取出'
rect.innerHTML +='<br>' //banana, apple
food.sort()
rect.innerHTML += 'Sort '
for(i=0;i<9;i++){
rect.innerHTML += ' '
}
rect.innerHTML += ': '
for (i=0;i<food.length; i++) {
rect.innerHTML += `${food[i]} `
}
for(i=0;i<9;i++){
rect.innerHTML += ' '
}
rect.innerHTML += '// 排序'
rect.innerHTML +='<br>' //banana, apple
</script>
</body>
</html>