← Back to challenges

Burglary Series (04): Add its Name

JavaScriptHardobjectslanguage_fundamentals

Instructions

Given three arguments ⁠— an object obj of the stolen items, the pets name and a value ⁠— return an object with that name and value in it (as key-value pairs).

Examples

addName({}, "Brutus", 300) ➞ { Brutus: 300 }

addName({ piano: 500 }, "Brutus", 400) ➞ { piano: 500, Brutus: 400 }

addName({ piano: 500, stereo: 300 }, "Caligula", 440) ➞ { piano: 500, stereo: 300, Caligula: 440 }

Notes

The value argument will be a number.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Derivative of a Function