-
Notifications
You must be signed in to change notification settings - Fork 32
/
03-arrays.html
45 lines (36 loc) · 1.08 KB
/
03-arrays.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
const favoriteCookies = [
"chocolate chip", //0
"iced oatmeal", //1
"sugar cookie", //2
45 //3
];
console.log(favoriteCookies[2]);
favoriteCookies[3] = "sandwich cookie";
favoriteCookies.push("butter cookies");
const favoriteCereal = [];
favoriteCereal.push("Frosted Flakes");
favoriteCereal.push("Cap'n Crunch");
console.log(favoriteCereal);
favoriteCereal.pop();
// console.log(favoriteCookies);
console.log(favoriteCereal);
// how do you create an array?
const shoes = []; // length of 0
shoes.push("Jordan 13"); // length of 1
// console.log(shoes.length);
shoes[0] = "Jordan 11";
// console.log(shoes[0]);
shoes.pop();
console.log(shoes);
</script>
</body>
</html>