-
Notifications
You must be signed in to change notification settings - Fork 0
/
JsArray.html
61 lines (37 loc) · 1.45 KB
/
JsArray.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
<!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 favoritmatratter = ["Pizza", "Sushi", "Tacos", "Pasta", "Burgare"];
let matratterText = "Mina favoritmaträtter är: ";
for (let i = 0; i < favoritmatratter.length; i++)
{
matratterText += "" + favoritmatratter[i] + ", ";
}
console.log(matratterText.slice(0, -2));
for (let i = 0; i < favoritmatratter.length; i++)
{
matratterText += "" + favoritmatratter[i] + ", ";
}
console.log(matratterText.slice(0, -2));
let färger = ["Blå", "Röd", "Grön", "Gul", "Lila"];
console.log("Mina favorit färger: " + färger.join(", "));
färger.push("Orange");
console.log("Nya färger: " + färger.join(", "));
färger.splice(2, 1);
console.log("Nya färger: " + färger.join(", "));
let stader = ["Stockholm", "Göteborg", "Malmö", "Uppsala", "Linköping"];
stader.unshift("Lund");
stader.pop();
stader.push("Örebro");
stader.splice(0, 0, "Göteborg");
console.log("Uppdaterade städer: " + stader.join(", "));
</script>
</body>
</html>