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),
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".
var accounts = { BankOfAmerica: { number: 12345 , nickname: "BA" , city: "Los Angeles" , checking: true , services: { stolen: true , creditReport: true } } , Chase: { number: 78910 , nickname: "Ch" , city: "San Diego" , checking: false , services: { stolen: false , creditReport: true } } , WellsFargo: { number: 11223 , nickname: "WF" , city: "Los Angeles" , checking: true , services: { stolen: false , creditReport: false } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started