Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 1.43 KB

array.md

File metadata and controls

25 lines (17 loc) · 1.43 KB

🔓 Array

Earlier, we have learnt how to create an array. Over here, we will learn how to print the items in an array using a for loop.

Using the same example in array:

const colours = ['red','orange','yellow','green','blue','indigo','purple'];

Now, let's try printing the item in the array using a for loop as shown below:

for (let count = 0; count < colours.length; count ++){
    console.log(colours[count]);
}

ℹ️ colours[count] refers to the item in array colours, with the index number equivalent to count. If count = 0, colours[count] --> colours[0] --> 'red'






◀️ Previous Page : Control Flow : Object 🚩 🔓                                     🏡                                       ▶️ Next Page : Control Flow : Function 🚩 🔓