Upload files to "arrays"
This commit is contained in:
23
arrays/Example2.js
Normal file
23
arrays/Example2.js
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// creating an array of strings
|
||||
let animals = ["Zebra", "Koala", "Lion", "Elephan", "Eagle"]
|
||||
|
||||
// displaying the items stored in array animals using a for loop
|
||||
for(let i=0; i<animals.length; i++)
|
||||
{
|
||||
let item = animals[i] // gets item at location i
|
||||
console.log('Item ' +i +": " +item)
|
||||
}
|
||||
|
||||
console.log()
|
||||
// displaying the items using the for-in loop
|
||||
for(let i in animals)
|
||||
{
|
||||
let item = animals[i] // gets item at location i
|
||||
console.log('Item ' +i +": " +item)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user