Converts HTML entities to their corresponding characters in a string
Overall
score
85%
Evaluation — 85%
↑ 1.39xAgent success when using this tile
Build a utility that normalizes field names in API responses to different naming conventions based on configuration.
You need to create a field name normalizer that can transform object keys in API response data according to specified naming conventions. The normalizer should support converting between different case styles commonly used in APIs (e.g., converting database snake_case to JavaScript camelCase, or vice versa).
Your solution should:
camel: camelCase (e.g., firstName)snake: snake_case (e.g., first_name)kebab: kebab-case (e.g., first-name)@generates
/**
* Normalizes field names in an object to a specified naming convention.
*
* @param {Object} data - The object whose keys should be normalized
* @param {string} convention - The target naming convention ('camel', 'snake', or 'kebab')
* @returns {Object} A new object with normalized keys
*/
function normalizeFields(data, convention) {
// Implementation here
}
module.exports = { normalizeFields };{ first_name: "John", last_name: "Doe" } with convention camel, it returns { firstName: "John", lastName: "Doe" } @test{ firstName: "Jane", lastName: "Smith" } with convention snake, it returns { first_name: "Jane", last_name: "Smith" } @test{ user_id: 123, is-active: true } with convention kebab, it returns { "user-id": 123, "is-active": true } @test{ user_data: { first_name: "Bob" } } with convention camel, it returns { userData: { firstName: "Bob" } } @testProvides utility functions for data transformation.
Install with Tessl CLI
npx tessl i tessl/npm-lodash-unescapedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10