Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Javascript: Your function should receive an object as its only argument and return an object with the same properties, but with type validation added. Types

Javascript: Your function should receive an object as its only argument and return an object with the same properties, but with type validation added. Types
should be validated when:
the function creates the object;
someone updates a property;
someone adds a property.
The type validation should always be based on the last part of the property name. For example, the age_int property should always be an integer
and throw an error when set to something else.
Here are possible types:
string: for example, "string type"
int: 12.00 and 12 are both integers
float: for example, 12.34
number: any int or float
bool: for example, true
Assumptions
Types are optional and validation should be skipped if the type isn't specified.
_ always precedes the type name.
Hints
JavaScript Proxy might be useful.
Your solution will be evaluated based on its correctness; performance and coding style will not be assessed.
Do not edit the default export.
Available tools/packages
Node.js 18.9.0
image text in transcribed

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 Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago