# FAQ: Write Expressive Tests - assert.deepEqual II

This community-built FAQ covers the “assert.deepEqual II” exercise from the lesson “Write Expressive Tests”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise assert.deepEqual II

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

If assert.deepEqual should be equivalent to assert.equal to arrays, because they both return a loose equality,
I understand a test should pass with either:

``````let expected = [3, 4, 7];
let sum = [3, 4];

// Exercise
sum.push(3 + 4);

// Verify
assert.deepEqual(sum, expected);
``````

or

``````assert.equal(sum, expected);
``````

As both return [3,4,7]
In fact, it should also return as passes using .strictEqual, as all are number.

Why does the test fails when anything besides .deepEqual?

I was wondering the same thing for a moment, but then:

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.

It’s a little confusing, I guess, since it can’t compare distinct objects/arrays, but with deepEqual it can AND it uses loose equality in its comparison of their values.

In the documentation, that’s linked in the section of this unity as well, it’s written that the use of assert.deepEqual is deprecated:

https://nodejs.org/api/assert.html#assert_assert_deepequal_actual_expected_message

1 Like