Created
September 19, 2016 20:28
-
-
Save mrailton/a60bb26644807471b4fe72efa1f1d312 to your computer and use it in GitHub Desktop.
whatCanIDrink
This file contains hidden or 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
function whatCanIDrink(age) { | |
if (age < 0) { | |
return "Sorry. I can’t tell what drink because that age is incorrect!"; | |
} else if (age < 14) { | |
return "Drink Toddy" | |
} else if (age < 18) { | |
return "Drink Coke" | |
} | |
} |
This file contains hidden or 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
describe("whatCanIDrink", function () { | |
it('should return an error if age is less than 0', function () { | |
expect(whatCanIDrink(-1)).toBe("Sorry. I can’t tell what drink because that age is incorrect!") | |
}); | |
it('should return Drink Toddy! if age is 13', function () { | |
expect(whatCanIDrink(13)).toBe("Drink Toddy") | |
}); | |
it('should return Drink Coke! if age is 17', function () { | |
expect(whatCanIDrink(17)).toBe("Drink Coke") | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment