Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Challenge 3 : Booleanize Object ### Objective Develop the ` booleanize ` function so it transforms an object's properties based on the criteria listed

# Challenge 3: Booleanize Object
### Objective
Develop the `booleanize` function so it transforms an object's properties based on the criteria listed (see requirements below). This function will loop over each property in the object and apply certain transformations to its values, while also handling edge cases related to property names.
### Function
```javascript
function booleanize(obj)
```
#### Parameters
-**obj:** An object with any number of properties.
## Requirements
1. Transform any value of zero (`0`) into the boolean `false`.
2. Transform any value of one (`1`) into the boolean `true`.
3. If a value is `null`, delete the entire key-value pair from the object.
4. If any _property_ name exceeds 9 characters, return the string `"shorten all prop names to 9 chars or less"`.
### Maintain Original Object Structure
- Ensure no unintended changes are made to the object's structure or other properties.
### Examples
#### Example 1
```javascript
let obj ={
keyZero: 0,
keyOne: 1,
keyNull: null,
keyTwo: 2
};
let result = booleanize(obj);
console.log(result);
```
Expected Output:
```javascript
{
keyZero: false,
keyOne: true,
keyTwo: 2
}
```
#### Example 2
```javascript
let obj ={
veryLongPropertyName: 0,
keyOne: 1
};
let result = booleanize(obj);
console.log(result);
```
Expected Output:
```javascript
"shorten all prop names to 9 chars or less"
```

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_2

Step: 3

blur-text-image_3

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions