Social Icons

Pages

Wednesday, November 30, 2016

Introduction to Objects I 7/33

Properties
Let's review what we previously covered. Each piece of information we include in an object is known as a property. Think of a property like a category label that belongs to some object. When creating an object, each property has a name, followed by : and then the value of that property. For example, if we want Bob's object to show he is 34, we'd type in age: 34.
age is the property, and 34 is the value of this property. When we have more than one property, they are separated by commas. The last property does not end with a comma.

Instructions
See the console for the object I have created about myself. Can you create an object calledme that describes your age and which country you live in?

var Spencer = {
  age: 22,
  country: "United States"
};
var me = {
  age: 18,
  country: "United States"
};

No comments:

Post a Comment