Created
January 3, 2016 20:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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