How to assert nested array with other expected array

  arrays, assertion, javascript

How to easily assert nested array elements with another array values? I tried the following but it’s not working as expected.

var expectedCells = ['a', 'b', 'c', 'd']
var actual = [['a'], ['b', 'e'], ['e'], ['c']] //['b', 'e'] should also return true 
actual.forEach(element => console.log(expectedCells.includes(element))); 

//Expected: true, true, false, true but it returns false, false, false, false

Source: Ask Javascript Questions

LEAVE A COMMENT