Tell us what’s happening:
Test is not accepting the last one, even though it is fulfilling the criteria. All other tests are succeeding but only this one is failing. Here is the code for my displaying the results
Your code so far
function displayChange(arr) {
if (getTotalCID() <= 0) {
changeDueDiv.innerHTML = `
<p class="status-p">Status: <span class="status-span">CLOSED</span></p>`;
} else {
changeDueDiv.innerHTML = `
<p class="status-p">Status: <span class="status-span">OPEN</span></p>`;
}
arr.forEach((value, index) => {
if (value || index > 4) {
changeDueDiv.innerHTML += `
<p class="status-p">${cid[index][0]}: <span class="status-span">$${value}</span></p>
`
}
});
}
Challenge Information:
Build a Cash Register Project - Build a Cash Register
sanity
January 4, 2024, 5:27am
2
Last test has a bug, you can see details at:
opened 08:40PM - 21 Dec 23 UTC
help wanted
scope: curriculum
type: showstopper
new javascript course
### Describe the Issue
It looks like the expected array is wrong in the last … test.
Also, I'm not sure if it should only account for what is the same. Just because the output _does_ contain the expected doesn't mean it can't contain _more_ than the expected.
Tests: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md
### Affected Page
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/build-a-cash-register-project/build-a-cash-register
### Your code
```
const expected = ['Status: OPEN', 'QUARTER: $0', 'DIME: $0', 'NICKEL: $0', 'PENNY: $0.5'];
let text = 'Status: OPEN ONE HUNDRED: $0 TWENTY: $0 TEN: $0 FIVE: $0 DOLLAR: $0 ONE: $0 QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5'
let result = expected.every(str => text.trim().toLowerCase().includes(str.toLowerCase()))
console.log(result); // true
```
### Expected behavior
Test not to pass with the wrong code.
### Screenshots
_No response_
### System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
### Additional context
Forum: https://forum.freecodecamp.org/t/cash-register-bug/657207
system
Closed
July 4, 2024, 5:28pm
3
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.