https://youtu.be/FdpIiPLcDOU

The include() and notInclude() methods are really useful. They can be used to check if an array contains a particular element, or to query an object. The first argument is the item we are looking in, and the second argument is the value we are looking for.

Solution

Our aim in each challenge is to make the tests pass, which are designed to fail by default. The best approach is to look at what the input is, and decide which test will make it pass.

The winterMonths array does not contain the string 'jul' so we should use notInclude here.

The backendLanguages array does contain the string 'javascript', so if we use include() here, it will pass.

var winterMonths = ['dec,','jan', 'feb', 'mar'];
var backendLanguages = ['php', 'python', 'javascript', 'ruby', 'asp'];
/** 12 - #include vs #notInclude **/
test('Array #include, #notInclude', function() {
  assert.notInclude(winterMonths, 'jul', "It's summer in july...");
  assert.include(backendLanguages, 'javascript', 'JS is a backend language !!');
});

Concepts

assert.include()

Asserts that haystack includes needle. Can be used to assert the inclusion of a value in an array, a substring in a string, or a subset of properties in an object. Strict equality (===) is used. When asserting the inclusion of a value in an array, the array is searched for an element that’s strictly equal to the given value. When asserting a subset of properties in an object, the object is searched for the given property keys, checking that each one is present and strictly equal to the given property value.

Assert

assert.notInclude()

Asserts that haystack does not include needle. Can be used to assert the absence of a value in an array, a substring in a string, or a subset of properties in an object. Strict equality (===) is used. When asserting the absence of a value in an array, the array is searched to confirm the absence of an element that’s strictly equal to the given value. When asserting a subset of properties in an object, the object is searched to confirm that at least one of the given property keys is either not present or not strictly equal to the given property value.

Assert