Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hello can anyone help me write this code out using javascript? To start, assign an employee variable to an Object containing name and streetAddress keys;

hello can anyone help me write this code out using javascript?

To start, assign an employee variable to an Object containing name and streetAddress keys; you can use whatever values you like. Use literal syntax to create your Object. Various updates will be applied to this variable (destructively and non-destructively) in this lab.

Once you've initialized the employee Object, you'll need to create the following four functions:

  • updateEmployeeWithKeyAndValue(): this function should take in three arguments: an employee Object, a key and a value. This function should not mutate the employee; it should return a new Object that has an updated value for the key passed in. Hint: use the spread operator!
  • destructivelyUpdateEmployeeWithKeyAndValue(): this function should work the same as updateEmployeeWithKeyAndValue()but it should mutate the employee Object passed in.
  • deleteFromEmployeeByKey(): this function should take in a employee Object and a key. It should delete the property with that key from the employee Object. This should not mutate the original employee Object; it should return a new Objectthat doesn't include the identified key-value pair. Hint: use the spread operator!
  • destructivelyDeleteFromEmployeeByKey(): this function should work the same as deleteFromEmployeeByKey() but it shouldmutate the employee Object.

As you work on your functions, be sure to think about when to use dot notation vs. bracket notation.

image text in transcribed
Let's say we are working on a program that will keep track of a company's employees. We want to store each employee as an object. We're starting small, so to begin with well only keep track of the employee's name and street address. To start, assign an employee variable to an object containing none and streetAddress keys: you can use whatever values you like. Use literal syntax to create your Object. Various updates will be applied to this variable (destructively and non-destructively) in this lab. Once you've initialized the employee Object, you'll need to create the following four functions: - UpdateEmployeeWithKeyAndVaLueO : this function should take in three arguments: an This function should not mutate the employee ; it should return a new object that has an updated value for the key passed in. Hint: use the spread operator! - destructivelyUpdateEmployeeNi thKeyAndValue() : this function should work the same as updateEeployeeWi thKeyAndValue() but it should mutate the employee object passed in. - detetefromEmployeeByKey() : this function should take in a employee object and a key. It should delete the property with that key from the employee object. This should not mutate the original employee object; it should return a new object that doesn't include the identified key-value pair. Hint use the spread operator! - destructivelyDeleteFromemployeeByKey() : this function should work the same as deletefromEmployeeByKey() but it should mutate the employee object

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago