diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md index 8728a846618..d0ba073a919 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md @@ -53,6 +53,27 @@ Fulfill the user stories and pass all the tests below to complete this project. # --hints-- +You should have the HTML file link to the JavaScript file. + +```js +const script = document.querySelector('script[data-src$="script.js"]'); +assert.isNotNull(script); +``` + +You should have a global variable called `price`. + +```js +price = 10; +assert.strictEqual(price, 10); +``` + +You should have a global variable called `cid`. + +```js +cid = []; +assert.isDefined(cid); +``` + You should have an `input` element with an `id` of `"cash"`. ```js @@ -119,7 +140,10 @@ cid = [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.1], ['QUARTER', 4.25], ['ON const expected = ['Status: OPEN', 'QUARTER: $0.5']; cashInput.dispatchEvent(new Event('change')); purchaseBtn.click(); -assert.isTrue(expected.every(str => changeDueDiv.innerText.trim().toLowerCase().includes(str.toLowerCase()))); +const result = changeDueDiv.innerText.trim().toLowerCase(); +assert.isTrue(expected.every(str => result.includes(str.toLowerCase()))); +const notExpected = [/PENNY/, /NICKEL/, /DIME/, /ONE [^H]/, /FIVE/, /TEN/, /TWENTY/, /ONE HUNDRED/]; +assert.isTrue(!notExpected.some(regex => result.match(new RegExp(regex, 'i')))) ``` When `price` is `3.26`, the value in the `#cash` element is `100`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: OPEN TWENTY: $60 TEN: $20 FIVE: $15 ONE: $1 QUARTER: $0.5 DIME: $0.2 PENNY: $0.04"`. @@ -136,7 +160,10 @@ cid = [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.1], ['QUARTER', 4.25], ['ON const expected = ['Status: OPEN', 'TWENTY: $60', 'TEN: $20', 'FIVE: $15', 'ONE: $1', 'QUARTER: $0.5', 'DIME: $0.2', 'PENNY: $0.04']; cashInput.dispatchEvent(new Event('change')); purchaseBtn.click(); -assert.isTrue(expected.every(str => changeDueDiv.innerText.trim().toLowerCase().includes(str.toLowerCase()))); +const result = changeDueDiv.innerText.trim().toLowerCase(); +assert.isTrue(expected.every(str => result.includes(str.toLowerCase()))); +const notExpected = [/NICKEL/]; +assert.isTrue(!notExpected.some(regex => result.match(new RegExp(regex, 'i')))) ``` When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: INSUFFICIENT_FUNDS"` @@ -185,7 +212,10 @@ cid = [['PENNY', 0.5], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], [ const expected = ['Status: CLOSED', 'PENNY: $0.5']; cashInput.dispatchEvent(new Event('change')); purchaseBtn.click(); -assert.isTrue(expected.every(str => changeDueDiv.innerText.trim().toLowerCase().includes(str.toLowerCase()))); +const result = changeDueDiv.innerText.trim().toLowerCase(); +assert.isTrue(expected.every(str => result.includes(str.toLowerCase()))); +const notExpected = [/NICKEL/, /DIME/, /QUARTER/, /ONE [^H]/, /FIVE/, /TEN/, /TWENTY/, /ONE HUNDRED/]; +assert.isTrue(!notExpected.some(regex => result.match(new RegExp(regex, 'i')))) ``` # --seed--