How do you create an array?


#1

its been long time since i have done them and i can't seem to figure out what it means by "make sure it has at least three elements"

#2

Any code that you have tried to write for this exercise?

I'd suggest to revise the things again. :slight_smile:
Or any confusion you have? you can put here.


#3

well if you want to see my code i haven't done much but here it is: var list = [""]; i t told me to make it var list but i didn't understand the rest


#4

and here is the page address if you need it: https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/0/1?curriculum_id=506324b3a7dffd00020bf661


#5

It says to create an array that should consist of 3 items (values/data)

How we create an array?
We set our variable equal to square bracket.

var x = [];

right now x is an empty array. (means it does not have any data/items inside it)

We can put many value when we just define it. (create it)
like this..

var x = [1,2,3,'Hello', true];

x have 5 items.

Note: in this exercise we have to create an array list that have 3 values/items.


#6

tell me if this is what you mean: var list = ["3,2,3,hi, true"]; because this doesn't work


#7

Well if you read instructions, then you will see ..

Create an array called list in the editor. It can contain any data you want! Make sure it has at least three elements.

But the data should be valid.
look at first item of your Array

"3 ? You mean string value 3? "3" ?
also hi , true" . These data are alien to javascript so it throws the error.


#8

thanks for the help i finally got it :slight_smile: :smile:


#9

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