Script Valley
JavaScript: The Complete Language
Objects, Arrays, and Destructuring/Assessment

Practice & Assessment

Test your understanding of Objects, Arrays, and Destructuring

Multiple Choice Questions

6
1

What is the output of the following? const obj = { a: 1 }; const copy = obj; copy.a = 99; console.log(obj.a);

2

Which array method should you use to create a new array with only elements that satisfy a condition?

3

What does the following destructuring do? const { a: x = 10 } = { b: 5 };

4

Where are methods defined with class syntax actually stored?

5

What does Array.prototype.splice do differently from Array.prototype.slice?

6

What does the 'in' operator check for on an object?

Coding Challenges

1
1

Object Deep Merge

Write a function deepMerge(target, source) that recursively merges two plain objects. If both target and source have a key whose value is an object, recursively merge those. Otherwise, source values overwrite target values. Input: two plain objects of any depth. Output: a new merged object (do not mutate inputs). Ignore array values — treat them as primitives (source wins). Time estimate: 25 minutes.

Medium

Mini Project

1

In-Memory Contact Book

Build a contact book module (Node.js) that stores contacts as an array of objects { id, name, email, phone, tags }. Implement: addContact(data) using spread for immutable insertion, getContact(id) using find, searchContacts(query) using filter across name and email, updateContact(id, changes) using map and spread (returns new array), deleteContact(id) using filter, and getByTag(tag) using filter and includes. All functions must be pure — no mutation of the original array. Use destructuring in function parameters and array destructuring where natural. Export all functions. Write a short demo script that calls all six functions and logs results.

Medium