function Item(name, sell_in, quality) {
  this.name = name;
  this.sell_in = sell_in;
  this.quality = quality;
}

var items = []

items.push(new Item('+5 Dexterity Vest', 10, 20));
items.push(new Item('Aged Brie', 2, 0));
items.push(new Item('Elixir of the Mongoose', 5, 7));
items.push(new Item('Sulfuras, Hand of Ragnaros', 0, 80));
items.push(new Item('Backstage passes to a TAFKAL80ETC concert', 15, 20));
items.push(new Item('Conjured Mana Cake', 3, 6));

function update_quality() {
  items.map(update_item);
}

function update_item(item) {
  if (item.name === 'Sulfuras, Hand of Ragnaros') {
    return;
  }

  if (item.name !== 'Aged Brie' && item.name !== 'Backstage passes to a TAFKAL80ETC concert') {
    if (item.quality > 0) {
      item.quality--;
    }
  } else {
    if (item.quality < 50) {
      item.quality++;
      if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
        if (item.sell_in < 11) {
          if (item.quality < 50) {
            item.quality++;
          }
        }
        if (item.sell_in < 6) {
          if (item.quality < 50) {
            item.quality++;
          }
        }
      }
    }
  }

  item.sell_in--;

  if (item.sell_in < 0) {
    if (item.name !== 'Aged Brie') {
      if (item.name !== 'Backstage passes to a TAFKAL80ETC concert') {
        if (item.quality > 0) {
          item.quality--;
        }
      } else {
        item.quality = 0
      }
    } else {
      if (item.quality < 50) {
        item.quality++;
      }
    }
  }
}

@@ -512,16 +512,151 @@
 em);%0A%7D%0A%0A
+var type = %7B%0A  Aging: 'Aged Brie',%0A  Legendary: 'Sulfuras, Hand of Ragnaros',%0A  Event: 'Backstage passes to a TAFKAL80ETC concert'%0A%7D;%0A%0A
 function
@@ -700,36 +700,22 @@
 === 
-'Sulfuras, Hand of Ragnaros'
+type.Legendary
 ) %7B%0A
@@ -751,27 +751,26 @@
 ame !== 
-'Aged Brie'
+type.Aging
  && item
@@ -783,51 +783,18 @@
 !== 
-'Backstage passes to a TAFKAL80ETC concert'
+type.Event
 ) %7B%0A
@@ -852,16 +852,18 @@
    %7D%0A  %7D
+%0A 
  else %7B%0A
@@ -940,51 +940,18 @@
  == 
-'Backstage passes to a TAFKAL80ETC concert'
+type.Event
 ) %7B%0A
@@ -1271,27 +1271,26 @@
 ame !== 
-'Aged Brie'
+type.Aging
 ) %7B%0A    
@@ -1313,51 +1313,18 @@
 !== 
-'Backstage passes to a TAFKAL80ETC concert'
+type.Event
 ) %7B%0A

Remove all hard-coded names