Converts HTML entities to their corresponding characters in a string
Overall
score
85%
Evaluation — 85%
↑ 1.39xAgent success when using this tile
Build a data parser utility that safely processes different data formats without throwing exceptions.
'{"name":"Alice","age":30}' returns the parsed object {name: "Alice", age: 30} @test'{bad json}' returns an error object @test'' returns an error object @test'42' returns the number 42 @test'abc' returns NaN @testtoUpperCase on string 'hello' returns 'HELLO' @testtoUpperCase on null value returns an error object @test@generates
/**
* Parses a JSON string safely, returning either the parsed value or an error.
*
* @param {string} jsonString - The JSON string to parse.
* @returns {Object|Error} The parsed object or an error object.
*/
function parseJSON(jsonString) {
// IMPLEMENTATION HERE
}
/**
* Parses an integer from a string safely, returning either the number or NaN.
*
* @param {string} str - The string to parse.
* @returns {number} The parsed integer or NaN.
*/
function parseInteger(str) {
// IMPLEMENTATION HERE
}
/**
* Executes a method on an object safely, returning either the result or an error.
*
* @param {*} obj - The object to execute the method on.
* @param {string} methodName - The name of the method to execute.
* @param {...*} args - Arguments to pass to the method.
* @returns {*|Error} The method result or an error object.
*/
function executeMethod(obj, methodName, ...args) {
// IMPLEMENTATION HERE
}
module.exports = {
parseJSON,
parseInteger,
executeMethod,
};Provides utility functions for safe function execution.
@satisfied-by
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