Implement a function deepMap(obj, fn) that recursively transforms all values in an object or array using the provided function.
The function should:
fn as the second argument.Example
const obj = { a: 1, b: { c: 2, d: [3, 4] } }; const result = deepMap(obj, x => x * 2); console.log(result); // { a: 2, b: { c: 4, d: [6, 8] } }
JavaScript Function
No test results yet
Click "Run" to execute tests