Skip to content

Instantly share code, notes, and snippets.

@astockwell
Last active December 17, 2015 23:19
Show Gist options
  • Save astockwell/5688788 to your computer and use it in GitHub Desktop.
Save astockwell/5688788 to your computer and use it in GitHub Desktop.
var output = document.getElementById('output');
function assert( outcome, description ) {
var li = document.createElement('li');
li.className = outcome ? 'pass' : 'fail';
li.appendChild( document.createTextNode( description ) );
output.appendChild(li);
};
// Useage:
function add(num1, num2) {
return num1 + num2;
}
var result = add(5, 20);
assert( result == 24, 'Checking the add function');
// OR
assert( add( 5, 20 ) == 24, 'Checking the add function');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment