16 Help requested!


#1


https://www.codecademy.com/de/courses/javascript-beginner-en-9Sgpi/3/3?curriculum_id=506324b3a7dffd00020bf661#

Oops, try again. Did you give your interests key an array value?


var myObject = {
  name: 'Eduardo',
  type: 'Most excellent',
  // Add your code here!
  interests: 'Sports'
};

why is 'sports' not a value? (I also tried it with "sports")
thanks for the help!


#2

It is a value, but it's a string value, not an array :slight_smile:

MDN reference - array


#3

what's the differance then? I'm really getting confused. does it need []?


#4

Yes.

The difference is that interests is a plural, you can have many interests, right? And you can represent them using an array:

['Sports', 'Programming', 'Progressive rock']

#5

oh okay thanks! :slight_smile:


#6

but then I'll ahve to define them first no? At least that's whta's poping up as error


#7

Can you post your code? After correction?

There was an unclosed string in the example posted by me, I corrected it. Sorry about that.


#8

var myObject = {
name: 'Eduardo',
type: 'Most excellent',
// Add your code here!
interests: [Sports, programming, trap, Marshmello]
};

error:
Oops, try again. Your code doesn't look quite right. Use the existing object keys/values as a guide! And check the error message for more information: ReferenceError: Sports is not defined


#9

Pretty good attempt, but this [Sports, programming, trap, Marshmello] is array of variables.

Sports -> variable with name Sports.
'Sports' -> a string, text value.

You need to create array of strings, so you need to add parentheses around every element of array.


#10

I love you! Thanks for explaining! :smile:


#11

Haha :slight_smile: You're very welcome :panda_face:


#12

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