Repository navigation
#290 Make a Copy
Adam Kubiś edited this page Oct 28, 2026
·
1 revision
Your spouse wants a copy of the stolen items. Given an object containing the stolen items, return a copy of that list.
Current source and tests | Catalog | Testing and tooling
From the cloned repository root, after installing dependencies:
node "Edabit/290 Make a Copy.js"Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.
This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.
//Your spouse wants a copy of the stolen items. Given an object containing the stolen items, return a copy of that list.
function makeCopy(obj) {
return { ...obj };
}
import { assertEquals, assertNotEquals } from '../testHelper.js';
const obj = { piano: 100 }
const obj2 = { stereo: 200 }
const obj3 = { tv: 300 }
assertNotEquals(makeCopy(obj), obj, "Return a copy of the obj, not the obj itself")
assertEquals(makeCopy(obj), obj)
assertNotEquals(makeCopy(obj2), obj2, "Return a copy of the obj, not the obj itself")
assertEquals(makeCopy(obj2), obj2)
assertNotEquals(makeCopy(obj3), obj3)
assertEquals(makeCopy(obj3), obj3)