Array exercise Problem


#1

Hi I lose the codes of the exercise and now I need to recheck it. Can you please tell me what s=are the codes of ‘Looping by hand’ exercise. My codes are following but they are incorrect.

var vacationSpots = [‘London’, ‘Pairas’, ‘Calgary’];

console.log(vacationSpots.listItem=[0]);

console.log(vacationSpots.listItem=[1]);
console.log(vacationSpots.listItem=[2]);

}
I need to write them in separate line.


#2

Hi @codemaster97099,

You mean to print in this order?

London
Pairas
Calgary

To access ‘London’ in the array, you need to write vacationSpots[0] where 0 is the first index position in the array.

To print, you need to use console.log


#3

The new Introduction to JS by Code Academy is way too easy. The older Intro to CS by CodeAcademy was a lot more challenging it took average of atleast 4 weeks. This intro to CS can be finished in 1 - 2 days; way too easy.

Maybe because I already know Computer Science?

For your code, you need to get rid of the equal sign. This finds the position of the array. If array[0] means it is at first position, if its array[1] its second position … The equal makes the [bracket Number] by it self, so it can’t find an array position in the log to the console of the variable.


#4

Hi @kevin20000k,

I can’t find what you mentioned about older Intro to CS by CodeAcademy? or did you mean intro to JS?

If it’s easy, then good for you. :wink:
Some users are still struggling with part of the exercises, syntax or concept-wise.

True that. However, without any mention of getting rid the .listItem after the vacationSpots where it should be vacationSpots[0], will send confusion to new beginners.

I don’t understand where .listItem came from to begin with. It’s not a method written for the code above.


#5

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