Chai-related error message: "AssertionError: expected undefined to deeply equal"
<p>I wrote a function that when given a list of objects and an
id, returns the same list, but with the corresponding object marked active
(all other objects should not be active). </p>

<pre><code>const list = [
     { id: 1, active: false },
     { id: 2, active: false },
     { id: 3, active: true  },
     { id: 4, active: false }
];

function markActive(list, value) {
  list.forEach((id) =&gt; {
    if (id.active = (id.id === value)) {
      return true;
    } else {
      return false;
    }
  });
}

markActive(list, 2);
console.log(list)
</code></pre>

<p>Returns:</p>

<pre><code>[ { id: 1, active: false },
  { id: 2, active: false },
  { id: 3, active: false },
  { id: 4, active: true } ]
</code></pre>

<p>It's working like a charm, except when I run "npm run [filename]" I get an error message: </p>

<pre><code>Running Tests for [filename].
------------
[ { id: 1, active: false },
  { id: 2, active: false },
  { id: 3, active: false },
  { id: 4, active: true } ]


  markActive
  1) Case 1 (Given Sample)
  2) Case 2 (String IDs)


  0 passing (16ms)
  2 failing

  1) markActive Case 1 (Given Sample):
     AssertionError: expected undefined to deeply equal [ { id: 1,        
     active: false },
     { id: 2, active: true },
     { id: 3, active: false },
     { id: 4, active: false } ]
     at Function.assert.deepEqual            
     (node_modules/chai/lib/chai/interface/assert.js:216:32)
      at Context.it (tests/test_02.js:23:12)

  2) markActive Case 2 (String IDs):
     AssertionError: expected undefined to deeply equal [ { id: '1',     
     active: false },
     { id: '2', active: true },
     { id: '3', active: false },
     { id: '4', active: false } ]
     at Function.assert.deepEqual   
     (node_modules/chai/lib/chai/interface/assert.js:216:32)
     at Context.it (tests/test_02.js:40:12)
</code></pre>

<p>Any idea what I'm doing wrong? Here's the code that sets up the tests:</p>

<pre><code>const chai    = require("chai");
const sinon   = require("sinon");
const assert  = chai.assert;

const markActive = require("../answers/02.js");

describe("markActive", () =&gt; {

  it("Case 1 (Given Sample)", () =&gt; {
  var list = [
         { id: 1, active: false },
         { id: 2, active: false },
         { id: 3, active: true  },
         { id: 4, active: false }
       ];
  var newList = markActive(list, 2);
  var targetList = [
         { id: 1, active: false },
         { id: 2, active: true  },
         { id: 3, active: false },
         { id: 4, active: false }
       ];
   assert.deepEqual(newList, targetList);
   });

  it("Case 2 (String IDs)", () =&gt; {
    var list = [
         { id: "1", active: false },
         { id: "2", active: false },
         { id: "3", active: true  },
         { id: "4", active: false }
       ];
    var newList = markActive(list, "2");
    var targetList = [
         { id: "1", active: false },
         { id: "2", active: true },
         { id: "3", active: false  },
         { id: "4", active: false }
       ];
    assert.deepEqual(newList, targetList);
  });

});
</code></pre>