Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MikeDigitize/b8edad945ce866b0f6cd to your computer and use it in GitHub Desktop.
Save MikeDigitize/b8edad945ce866b0f6cd to your computer and use it in GitHub Desktop.
Some coding challenges for the AO front end team who are learning JavaScript
// with three methods toBe, toBeExactly and toBeTypeof
function Assert(val) {
return {
toBe : function(expected) {
return val == expected;
},
toBeExactly : function(expected) {
return val === expected;
},
toBeTypeof : function(expected) {
return typeof val === expected;
}
};
};
function Assert(val) {
Assert.val = val;
return Assert;
}
Assert.toBe = function(expected) {
return this.val == expected;
};
Assert.toExactlyBe = function(expected) {
return this.val === expected;
};
Assert.toBeA = function(expected) {
return typeof this.val === expected;
};
var assert = {};
assert.expect = function(val){
this.val = val;
};
assert.toBe = function(expected) {
return this.val === expected;
};
Assert("1").toBe(1);
assert.expect("1").toBe(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment