https://youtu.be/NjkM9CoRt9g

We can give a value to the 'isString()' and 'isNotString()' tests to determine whether it is a valid string or not.

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.

In the first one, we call the sin() method, which returns a number. This is not a string, so we should use isNotString().

In the second one, process.env.PATH will be a string. Environment variables are returned as a string if they exist, or undefined if they don't All node projects have the PATH variable, so we can guarantee a string here. So use isString().

Finally, we have json.stringify() in the input. This always returns a JSON string, so we should use isString().

/** 13 - #isString asserts that the actual value is a string. **/
test('#isString, #isNotString', function() {
  assert.isNotString(Math.sin(Math.PI/4), 'a float is not a string');
  assert.isString(process.env.PATH, 'env vars are strings (or undefined)');
  assert.isString(JSON.stringify({type: 'object'}), 'a JSON is a string');
});

Concepts

assert.isString()

Assert

assert.isNotString()

Assert