Created
September 19, 2013 21:32
-
-
Save armonge/6630141 to your computer and use it in GitHub Desktop.
Kata #1 (Javascript) Webcast Agilityfeat. https://plus.google.com/114642677983172790710/posts/erAyjcXgkLp
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 fizzbuzz(number){ | |
if(number === 0){ | |
return '0'; | |
} | |
if(number % 3 === 0 && number % 5 === 0){ | |
return 'fizzbuzz'; | |
} | |
if(number % 3 === 0){ | |
return 'fizz'; | |
} | |
if(number % 5 === 0){ | |
return 'buzz'; | |
} | |
return number.toString(); | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>FizzBuzz</title> | |
<link rel="stylesheet" href="/resources/qunit-1.12.0.css"> | |
</head> | |
<body> | |
<div id="qunit"></div> | |
<div id="qunit-fixture"></div> | |
<script src="/resources/qunit-1.12.0.js"></script> | |
<script src="/resources/fizzbuzz.js"></script> | |
<script src="/resources/tests.js"></script> | |
</body> | |
</html> |
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
test('classify as is', function(){ | |
ok(fizzbuzz(0) === '0', 'Passed!'); | |
ok(fizzbuzz(1) === '1', 'Passed!'); | |
}); | |
test('classify as fizz', function(){ | |
ok(fizzbuzz(3) === 'fizz', 'Passed!'); | |
ok(fizzbuzz(6) === 'fizz', 'Passed!'); | |
}); | |
test('classify as buzz', function(){ | |
ok(fizzbuzz(5) === 'buzz', 'Passed!'); | |
ok(fizzbuzz(10) === 'buzz', 'Passed!'); | |
}); | |
test('classify as fizzbuzz', function(){ | |
ok(fizzbuzz(15) === 'fizzbuzz', 'Passed!'); | |
ok(fizzbuzz(30) === 'fizzbuzz', 'Passed!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment