Skip to content

Instantly share code, notes, and snippets.

@vstarck
Last active December 11, 2015 14:18

Revisions

  1. vstarck revised this gist Jan 24, 2013. 1 changed file with 28 additions and 6 deletions.
    34 changes: 28 additions & 6 deletions fizzbuzz.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,16 @@
    function fizzBuzz(from, to) {
    function print() {
    var text =
    ',,Fizz'.split(',')[from%3] +
    ',,,,Buzz'.split(',')[from%5]
    'Fizz,,'.split(',')[from%3] +
    'Buzz,,,,'.split(',')[from%5]

    var _ = {}

    _[text] = ''
    _[''] = from

    console.log(
    text + _[text]
    from, ' -> ', text + _[text]
    )
    }

    @@ -26,10 +26,32 @@ function fizzBuzz(from, to) {
    function loop() {
    print()
    next()
    }

    }

    loop()
    }

    fizzBuzz(1, 20)
    fizzBuzz(1, 20)

    /*
    1 -> 1
    2 -> 2
    3 -> Fizz
    4 -> 4
    5 -> Buzz
    6 -> Fizz
    7 -> 7
    8 -> 8
    9 -> Fizz
    10 -> Buzz
    11 -> 11
    12 -> Fizz
    13 -> 13
    14 -> 14
    15 -> FizzBuzz
    16 -> 16
    17 -> 17
    18 -> Fizz
    19 -> 19
    20 -> Buzz
    */
  2. vstarck revised this gist Jan 24, 2013. 1 changed file with 15 additions and 11 deletions.
    26 changes: 15 additions & 11 deletions fizzbuzz.js
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,35 @@
    function fizzBuzz(from, to) {
    function print() {
    var text =
    ',,Fizz'.split(',')[from%3] +
    var text =
    ',,Fizz'.split(',')[from%3] +
    ',,,,Buzz'.split(',')[from%5]

    var _ = {}

    _[text] = ''
    _[''] = from

    console.log(
    text + _[text]
    )
    }

    function loop() {
    function next() {
    var _ = {}

    _[from] = loop
    _[to] = function() {}
    _[to] = function() {}

    _[from++]()
    }

    function loop() {
    print()
    _[from++]()
    next()
    }


    loop()
    }

    fizzBuzz(1, 20)


    fizzBuzz(1, 20)
  3. vstarck revised this gist Jan 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fizzbuzz.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ function fizzBuzz(from, to) {
    }

    function loop() {
    var _ = []
    var _ = {}

    _[from] = loop
    _[to] = function() {}
  4. vstarck created this gist Jan 23, 2013.
    31 changes: 31 additions & 0 deletions fizzbuzz.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    function fizzBuzz(from, to) {
    function print() {
    var text =
    ',,Fizz'.split(',')[from%3] +
    ',,,,Buzz'.split(',')[from%5]

    var _ = {}

    _[text] = ''
    _[''] = from

    console.log(
    text + _[text]
    )
    }

    function loop() {
    var _ = []

    _[from] = loop
    _[to] = function() {}

    print()
    _[from++]()
    }

    loop()
    }

    fizzBuzz(1, 20)