Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Answer this question with thumb up - Using Javascript to write and js to run) Write a function, addColourPreference, which takes a user argument, an

(Answer this question with thumb up - Using Javascript to write and js to run)

Write a function, addColourPreference, which takes a user argument, an Object, and a colour string argument and returns the user Object with a new Colour Preference property. Your function should work like this:

let user = { name: "Yan" }; user = addColourPreference(user, 'red'); 

The user object should now how a Colour Preference property with the value red, that is, the user object would look like this:

{ name: Yan, Colour Preference: red} 

Part 2 (3 Marks)

Similar to Part 1, write a function, removeColourPreference, which takes a user argument, an Object, and returns the user Object with a the Colour Preference property removed. Your function should work like this:

let user = { name: "Yan" }; // Add a Colour Preference of red user = addColourPreference(user, 'red'); // Remove Colour Preference from the user user = removeColourPreference(user); 

After calling your function, the user object should NOT have a Colour Preference property: { name: Yan }

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago