40 lines
626 B
Plaintext
40 lines
626 B
Plaintext
let arr = [10, 20, 30, 40, 50]
|
|
print(arr)
|
|
|
|
print(arr[0] + arr[4])
|
|
|
|
let i = 1
|
|
while(i < 4) {
|
|
print(arr[i])
|
|
i = i + 1
|
|
}
|
|
|
|
arr[0] = 99
|
|
print(arr)
|
|
|
|
for (let j = 0; j < 3; j = j + 1) {
|
|
arr[j] = arr[j] * 2
|
|
}
|
|
print(arr)
|
|
|
|
let nested = [[1, 2], [3, 4], [5, 6]]
|
|
print(nested[1][0])
|
|
|
|
let empty = []
|
|
print(empty)
|
|
|
|
let mixed = [1, "hello", true, nil]
|
|
print(mixed)
|
|
print(mixed[1][0])
|
|
|
|
let same = [1, 2, 3]
|
|
let other = [1, 2, 3]
|
|
print(same == other)
|
|
print(same != [3, 2, 1])
|
|
|
|
let item = { name: "sword", price: 100 }
|
|
let items = [item, { name: "shield", price: 50 }]
|
|
print(items[0].name)
|
|
items[1].price = 75
|
|
print(items[1].price)
|