Question:

Create a sally object with first_name, last_name, and full_name properties with object literal notation, similar to the following example.

var bob = {
  first_name: "Bob",
  last_name: "Lob",
  full_name: function () {
    return this.first_name + " " + this.last_name
  }
}

Answer:

var sally = {
  first_name: "Sally",
  last_name: "Mae",
  full_name: function () {
    return this.first_name + " " + this.last_name
  }
}

The sally_object is similar to the bob object and it was tedious retyping all this code to create a separate object with the same behavior. In this quiz, constructor functions are introduced to facilitate the creation of similar objects.


Keywords:

© 2017 QuizBucket.org