Skip to content

Instantly share code, notes, and snippets.

@swartzrock
Last active December 20, 2015 09:18
Show Gist options
  • Save swartzrock/6106334 to your computer and use it in GitHub Desktop.
Save swartzrock/6106334 to your computer and use it in GitHub Desktop.
Sample from Programming JavaScript Applications - Early Release from OReilly Books.
var highPass = function highPass(number, cutoff) {
if (number >= cutoff) {
return true;
} else {
return false;
}
},
lowPass = function lowPass(number, cutoff) {
if (number >= cutoff) {
return true;
} else {
return false;
}
};
module('Filter Examples');
test('highPass', function () {
ok(!highPass(2, 5), 'Lower values should not pass.');
ok(highPass(8, 5), 'Higher values should pass.');
});
test('lowPass', function () {
ok(lowPass(2, 5), 'Lower values should pass.'); // Fails
ok(!lowPass(8, 5),
'Higher values should not pass.'); // Fails
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment