From 5367b03ff53f671e26a6a3262f46e6e62ecae146 Mon Sep 17 00:00:00 2001 From: Benjamin Barreto <4544900-benalexb@users.noreply.gitlab.com> Date: Wed, 21 Oct 2020 16:21:27 +0200 Subject: [PATCH] Missing logic dissection --- js-jest/src/gilded_rose.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js-jest/src/gilded_rose.js b/js-jest/src/gilded_rose.js index b9aff7a3..dc571818 100644 --- a/js-jest/src/gilded_rose.js +++ b/js-jest/src/gilded_rose.js @@ -34,7 +34,6 @@ class RegularItem extends Item { const isNameValid = typeof name === 'string' && name.length const isSellInValid = typeof sellIn === 'number' - // "The Quality of an item is never negative" // "The Quality of an item is never more than 50" const isQualityValid = typeof quality === 'number' && quality >= 0 && quality <= 50 @@ -98,13 +97,16 @@ class Shop { if (this.items[i].name !== 'Backstage passes to a TAFKAL80ETC concert') { if (this.items[i].quality > 0) { if (this.items[i].name !== 'Sulfuras, Hand of Ragnaros') { + // Not cheese, not pass, not sulfuras, therefore regular item this.items[i].quality = this.items[i].quality - 1 } } } else { + // Maybe pass (could be sulfuras), quality is zero because sellIn is negative this.items[i].quality = this.items[i].quality - this.items[i].quality } } else { + // Is cheese, increment quality by 1 because sellIn is negative if (this.items[i].quality < 50) { this.items[i].quality = this.items[i].quality + 1 }