let allStars = ["James", "Davis", "Harden", "Doncic", "Leonard"]
for player in allStars {
print(player)
}
prints all elements in the array
James
Davis
Harden
Doncic
Leonard
for i in 0..<10 {
print(i)
}
output
0
1
2
3
4
5
6
7
8
9
adds random number from 50 to 100 in the array randomNumber using for loop.
var randomNumber: [Int] = []
for i in 0..<25 {
let randomNum = Int.random(in: 50...100)
randomNumber.append(randomNum)
}
print(randomNumber)
output
[69, 79, 86, 73, 62, 67, 52, 54, 99, 82, 88, 69, 70, 65, 51, 70, 79, 83, 96, 79, 68, 80, 71, 52, 64]