There is an array of 10 students below in the code part. I wanted to display that as
- Aaran
- Aaren
- Aarez ...up to 10
but I am unable to achieve this using for a loop as the index starts from 0 but if I start it from 1 then it skips the first name.
Here is my code below:
var stu = ["Aaran", "Aaren", "Aarez", "Aarman", "Aaron", "Aaron-James", "Aarron", "Aaryan", "Aaryn", "Aayan"]
// 1. counting the students names:
var ln = stu.length;
//2. showing the students names using for loop with numbering:
for (var i = 1; i < ln; i++) {
document.write(i + " : " + stu[i] + "<br>")
}
It gives me numbers like 1, 2, 3 but it skips the first item of the array. So how can I achieve this without skipping?