# JavaScript: Objects and Arrays Quiz

## JavaScript: Objects and Arrays Quiz

???

## JavaScript: Objects and Arrays Quiz

?: Given a number of elements that need to stay in order, would you use an Object or an Array?

( ) Object (x) Array

?: Given a collection of artists and lists of their songs, would you store the artist-song-list pairs in an Object or an Array?

(x) Object ( ) Array

?: True or false: All the elements in an array must be of the same type.

( ) True (x) False

?: True or false: All keys in an object are strings.

(x) True ( ) False

?: What happens to the array in the following code snippet?

```
const dogs = ["Fido", "Odie", "Oscar"]

dogs.length

dogs.length = 1
```

( ) Nothing ( ) The array becomes just `["Oscar"]` (x) The array becomes just `["Fido"]` ( ) The array becomes just `["Odie", "Oscar"]`

?: What are the keys in the object after running the code below?

```
const artistsAndSongs = {
  'Prince': ["Purple Rain", "When Doves Cry"],
  'The Beatles': ["Revolution", "Norwegian Wood"],
  'Joni Mitchell': ["A Case of You", "Sunny Sunday"],
  'Justin Bieber': ["Baby"]
}

artistsAndSongs['Daft Punk'] = ["Harder, Better, Faster, Stronger"]

delete artistsAndSongs["Justin Bieber"]
```

( ) `['Prince', 'The Beatles', 'Joni Mitchell', 'Justin Bieber', 'Daft Punk']` ( ) `['Prince', 'The Beatles', 'Joni Mitchell', 'Justin Bieber']` ( ) `['Prince', 'The Beatles', 'Joni Mitchell']` (x) `['Prince', 'The Beatles', 'Joni Mitchell', 'Daft Punk']`

?: If we run `artistsAndSongs['Daft Punk'].push("Around the World")` after running the code below, what is the value of the object?

```
const artistsAndSongs = {
  'Prince': ["Purple Rain", "When Doves Cry"],
  'The Beatles': ["Revolution", "Norwegian Wood"],
  'Joni Mitchell': ["A Case of You", "Sunny Sunday"],
  'Justin Bieber': ["Baby"]
}

artistsAndSongs['Daft Punk'] = ["Harder, Better, Faster, Stronger"]

delete artistsAndSongs["Justin Bieber"]
```

( )

```
const artistsAndSongs = {
  'Prince': ["Purple Rain", "When Doves Cry"],
  'The Beatles': ["Revolution", "Norwegian Wood"],
  'Joni Mitchell': ["A Case of You", "Sunny Sunday"],
  'Daft Punk': ["Harder, Better, Faster, Stronger"]
}
```

(x)

```
const artistsAndSongs = {
  'Prince': ["Purple Rain", "When Doves Cry"],
  'The Beatles': ["Revolution", "Norwegian Wood"],
  'Joni Mitchell': ["A Case of You", "Sunny Sunday"],
  'Daft Punk': ["Harder, Better, Faster, Stronger", "Around the World"]
}
```

( )

```
const artistsAndSongs = {
  'Prince': ["Purple Rain", "When Doves Cry"],
  'The Beatles': ["Revolution", "Norwegian Wood"],
  'Joni Mitchell': ["A Case of You", "Sunny Sunday"],
  'Daft Punk': ["Around the World"]
}
```

( )

```
const artistsAndSongs = {
  'Prince': ["Purple Rain", "When Doves Cry"],
  'The Beatles': ["Revolution", "Norwegian Wood"],
  'Joni Mitchell': ["A Case of You", "Sunny Sunday"]
}
```

?: What is the result of the following code in a browser that supports the spread operator?

```
const oneTwoThree = [1, 2, 3]
const sevenEightNine = [7, 8, 9]

const result = [4, 5, 6, ...oneTwoThree, ...sevenEightNine]
```

( ) `[4, 5, 6, 7, 8, 9, 1, 2, 3]` (x) `[4, 5, 6, 1, 2, 3, 7, 8, 9]` ( ) `[1, 2, 3, 4, 5, 6, 7, 8, 9]` ( ) `Error`

?: Given the array `const letters = ["alpha", "gamma", "delta"]`, which operation(s) *return* the array `["alpha", "beta", "gamma", "delta"]` ***without*** mutating (changing) the `letters` `Array`?

( ) `letters.push("beta")` ( ) `letters.unshift('beta')` (x) `[...letters.slice(0, 1), 'beta', ...letters.slice(1)]` ( ) `letters.splice(1, 1, 'beta')` ( ) `letters.splice(1, 0, 'beta')`

???

View [Javascript Objects And Arrays Quiz](https://learn.co/lessons/javascript-objects-and-arrays-quiz) on Learn.co and start learning to code for free.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://certil-remy.gitbook.io/learn/javascript/untitled-6/untitled-8.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
