Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create the following object literals: Create an object called car with the prope

ID: 3718014 • Letter: C

Question

Create the following object literals:

Create an object called car with the properties make(string), model(string),year(number).

Create an object called animal with the properties animalName(string),animalType(string), age(number), neutered(boolean).

Create an object called person with the properties firstName(string),lastName(string), age(number), occupation(string) and a property called addresswith properties: street (string), city(string), state(string) and zip(number) .

Updating Objects

Update the properties of the car object to a Honda Civic 2018. Console log the carobject.

Update the properties of the animal object to Chucho, dog, 3 years old, not neutered. Console log the animal object.

Update the properties of the person with the properties to John Smith, age 33, Musician who lives at 101 Code St, Los Angeles 00404 . Console log the person object.

Update the properties of the animal object using bracket notation to Fido, dog, 4 years old, neutered. Console log the animal object.

Add a new property using dot notation to the car object called VIN and set the value to N1234. Console log the car object.

Object Reflection

Use the typeof operator to inspect the properties of the accounts object on the code block below:

Console log the result of the typeof operator on the accounts object.

Console log the result of the typeof operator on the property Chase the accountsobject.

Console log the result of the typeof operator on the property number of the BankOfAmerica property.

Console log the result of the typeof operator on the property city of the WellsFargoproperty.

Console log the result of the typeof operator on the property stolen of the Chaseproperty.

Console log the result of the typeof operator on the value of null (????)

Retrieving Objects

Given the object accounts below:

Create a function called printServices. The function should take a parameter bank.This function should use the properties of the parameter bank to console log the services of the accounts by bank. The string should read as "{Account number}: stolen card: {true/false}, credit report: {true/false}" . Invoke the function with the each one of the properties (banks) of the accounts object. As an example, invoking the first property should result in "12345: stolen card: true, credit report: true".

Explanation / Answer

var car = new Object();
car.make;
car.model;
car.year;

var animal= new Object();
animal.animalName;
animal.animalType;
animal.age;
animal.neutered;

var person = new Object();
person.firstName;
person.lastName;
person.age;
person.occupation;
person.addresswith = new Object();
person.addresswith.street;
person.addresswith.city;
person.addresswith.state;
person.addresswith.zip;

2. Below code for updating Created Objects

car = {make: "Honda", model: "Civic", year: 2018};

console.log(car);

animal = {animalName: "Chucho", animalType: "dog", age: 3, neutered: false};

console.log(animal);

person = {firstName: "John", lastName: "Smith", age: 33, occupation: "Musician",

addresswith: {street: "101 Code St", city: "Los Angeles", state: "USA", zip: 00404}

};

console.log(person);

3. Using bracket notation to update animal Object

?animal['animalName'] = 'Fido';

animal['animalType'] = 'dog';

animal['age'] = 4;

animal['neutered'] = true;

console.log(animal);

4. Using dot operator to car object to create VIN pasroperty

car.VIN = "N1234";

console.log(car);

5. Object Reflection for given Accounts object is as below:

console.log(typeof(accounts));

console.log(typeof(accounts.Chase));

console.log(typeof(accounts.BankOfAmerica.number));

console.log(typeof(accounts.WellsFargo.city));

console.log(typeof(accounts.Chase.services.stolen));

console.log(typeof(null));

6. Retrieving Objects code is below

function printServices(bank){
console.log(bank.Accountnumber+": stolen card: " +bank.stolencard+", credit report: "
+bank.creditreport);
}
var accounts = new Object();
accounts.Accountnumber = 12345;
accounts.stolencard = true;
accounts.creditreport = false;
printServices(accounts);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote