Basic Data Structures - Use an Array to Store a Collection of Data

Tell us what’s happening:

What is wrong with my code? It has a boolean, strings and numbers.
The solution is made with a one-dimensional array, I made a multi dimensional array.

Your code so far

let yourArray = [
  [
    {
      one: 1,
      two: 2
    }
  ],
  [
    {
      a: "a",
      b: "b"
    }
  ],
  [
    {
      c: "c",
      d: "d"
    }
  ],
  [
    {
      e: "a",
      f: "b"
    }
  ],
  [
    {
      a: true,
      b: false
    }
  ]
];

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1.1 Safari/605.1.15

Challenge Information:

Basic Data Structures - Use an Array to Store a Collection of Data

yourArray need to directly contain the required elements, right now it contains only array, not strings, numbers or booleans

Ignore the complexArray example and just look at the simpleArray example. That is what you want your array to look like.

I wish thats what they told us when they added an example! Theres nothing that leads the user to writing a one-dimensional array.I wish thats what they told us when they added an example! Theres nothing that leads the user to writing a one-dimensional array.

Hi there!

The instructions is asking you: Complete the statement by assigning an array of at least 5 elements in length to the yourArray variable. Your array should contain at least one string, one number, and one boolean.

It’s not asked to add nested arrays or objects within the array, you just need to add required number of elements within a single array.

The requirements are what “leads the user to writing a one-dimensional array”.

But I do think the complex array example is an unnecessary detail that could confuse some users.

If you add one example and then add another example, you’re not gonna go and say “hmm the first example is better!” because you wont know that. You’ll be going for the latest example. At least make them accept both? fCC staff said that my array is wrong but its literally a copy of their example.

I would suggest you slow down and read the challenge text and requirements a few times.

It explains the array data structure and gives a simple example. Then it expands on that by informing you of the length property, and then gives a more complex array example.

Then it gives you the requirements, and they clearly state what the array you are asked to create should contain. It does not ask for arrays, or arrays of objects, you only added that because of the complexArray example.

The key takeaway is that an array only contain its own elements. Nested arrays or objects and their elements/properties does not count against the outer array content.

The below arr array does not contain a number, it contains an array. The fact that the nested array contains a number doesn’t matter.

const arr = [[1]]

If I ask for an array with a number inside it, it means if I were to run typeof arr[0] it would return "number"

const arr = [1];
console.log(typeof arr[0]); // 'number'

const arr2 = [[1]];
console.log(typeof arr2[0]); // 'object'
2 Likes

The example is an example of a multi-dimensional array.
You have written an array that contains arrays. You need an array that has three elements as requested, the other two (or more) can be what you want even arrays or objects:

Your array should contain at least one string, one number, and one boolean.

An array contains an element when the element is one of the items inside the array, not when it is inside an array or object inside the array