Question: 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
 Javascript: Your function should receive an object as its only argument

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!