Created
April 11, 2012 03:11
-
-
Save usagi/2356610 to your computer and use it in GitHub Desktop.
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
| var fizz_buzz = { | |
| range : { | |
| begin : 1, | |
| end : 100, | |
| }, | |
| test : function(target_value, test_value) { | |
| return target_value % test_value === 0; | |
| }, | |
| test_sets : [ | |
| { value: 3, word: 'Fizz!', }, | |
| { value: 5, word: 'Buzz!', }, | |
| ], | |
| }; | |
| for(var n = fizz_buzz.range.begin; n <= fizz_buzz.range.end; n = n + 1) { | |
| var words = ''; | |
| for(var key in fizz_buzz.test_sets) { | |
| var test = fizz_buzz.test_sets[key]; | |
| if ( fizz_buzz.test(n, test.value) ) | |
| words = words + test.word; | |
| } | |
| if ( words === '' ) | |
| words = String(n); | |
| console.log('n:' + n + ' "' + words + '"'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment