Do you think these assertions will throw errors?

const a = {relation: 'twin', age: '17'}; const b = {relation: 'twin', age: '17'}; assert.equal(a, b); assert.strictEqual(a, b);

Both assertions will throw an error because distinct objects are not considered equal when using either loose or strict equality in JavaScript.

If you need to compare the values within two objects, you can use assert.deepEqual(). This method compares the values of each object using loose (==) equality.

The following code will not throw an error…

assert.deepEqual(a, b);

…and you can confirm by manually comparing the relation and age properties of each object.

a.relation == b.relation; a.age == b.age;



Run the test suite. You should see an error thrown.


Replace assert.equal() with assert.deepEqual().


Run the test suite again.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?