Why do we add "Index"?


#1

Hi, I’m just curious as to why we add “index” to the variable in for loops. What is the point of this? Why can we just use the normal variable name? Thanks!

https://www.codecademy.com/courses/learn-javascript-loops/lessons/loops/exercises/for-loop?action=lesson_resume&course_redirect=introduction-to-javascript



Replace this line with your code. 



#2

It’s not compulsory.you can take any name for your iterator variable then use the same name to that variable to print the values.
for example:
if i use x as iterator variable then i have to write

vacationSpots[x]


#3

@digitalace66173 while the names can get really long its really there for specificity and readability, I think this naming convention works well for teaching also it reminds me of naming convention for css which can help you write class names that is quickly understood by other developers


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.