Upload files to "arrays"

This commit is contained in:
2025-10-27 12:26:06 -05:00
parent 3683031350
commit ef28aafda1
5 changed files with 146 additions and 0 deletions

23
arrays/Example2.js Normal file
View 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)
}