This is better than this

This:

changeSize: function(size) {
  $$('div.what_it_looks_like').invoke("hide");
  $(size).show();
}

is better than this.

changeSize: function(size) {
  switch(size) {
    case 'medium_rectangle' :
      $('medium_rectangle').show();
      $('skyscraper').hide();
      $('leaderboard').hide();
      break;
    case 'skyscraper' :
      $('medium_rectangle').hide();
      $('skyscraper').show();
      $('leaderboard').hide();
      break;
    case 'leaderboard' :
      $('medium_rectangle').hide();
      $('skyscraper').hide();
      $('leaderboard').show();
      break;
  }
}

And I’m still a Javascript n00b.

Advertisements