Skip to content

Instantly share code, notes, and snippets.

@leecrossley
Created March 28, 2012 12:36

Revisions

  1. leecrossley revised this gist Mar 28, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Happy Panda.
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    var panda = (function () {
    var panda, bambooLevel = 0, isAsleep = false;
    var panda = {}, bambooLevel = 0, isAsleep = false;

    function wakeUp() {
    isAsleep = false;
  2. leecrossley created this gist Mar 28, 2012.
    21 changes: 21 additions & 0 deletions Happy Panda.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    var panda = (function () {
    var panda, bambooLevel = 0, isAsleep = false;

    function wakeUp() {
    isAsleep = false;
    }

    panda.eatBamboo = function () {
    bambooLevel = bambooLevel + 1;
    };

    panda.goToSleep = function () {
    isAsleep = true;
    setTimeout(wakeUp, 1000);
    };

    return panda;
    })();

    panda.eatBamboo();
    panda.goToSleep();