(everything), you might want to benefit from a very simple assertion library such as chai - assert.
e.g. if you know a variable must be a string and must have a value of
'hello', simply write
// chai assert library
const assert = chai.assert;
let val = 'hell';
assert.isString(val, '"val" must be a string');
assert.strictEqual(val, 'hello', '"val" must have a value of "hello"');
then check your browser dev tools for any errors.
This is actually better than
console.loging (in some aspects) because your devtool console won’t get flooded with unnecessary logs.
Also the mind blowing benefit is you just learnt how to write “tests”. You will be praised a lot in future for this practice.
How to add to CodePen
- Go to your pen
- Click “Settings”
Check out http://codepen.io/abhisekp/pen/ezgLVg?editors=0010