Array is a very powerful concept in any programming language. It can strore same or any kind of object data in its elements.
cities = new Array(5);
cities = “Hyderabad”;
cities = “Kolkata”;
cities = “Delhi”;
cities = “Mumbai”;
cities = “Panaji”;
var elements= prompt(“Enter How Many elements”, “Elements”);
cities = new Array(elements);
var cities[i]= prompt(“Enter your city Name”, “City”);
Now to display those elements there are 3 ways:
One traditional for loop–
first find out the length of the array-
Second method could be more static
The Third method could be-
I like this method to display all the elements of an array.