Tell us what’s happening:
Hello there, my code for this project is passing all but the final user story, and I cannot figure out why. The function below is what turns an array of the types of currency being made into change into a string to set as the textContent of the #change-due element.
In my own testing it is spitting out the correct answer, but it is not accepted. I have added some console outputs to compare the string the test is asking for and the string that I am returning, and they are a perfect match. I have included the console output below.
Your code so far
function composeChangeDue(change) {
let string = `Status: ${isOpen ? "OPEN" : "CLOSED"} `;
if (change === undefined) {
string = "Status: INSUFFICIENT_FUNDS";
return string
}
const entries = Object.keys(change);
entries.forEach(entry => {
const subString = `${entry}: $${fixPrecision(change[entry])} `;
string += subString;
});
console.log(string);
return string.trim();
}
Console output:
// running tests
When price is 19.5, the value in the #cash element is 20, cid is [["PENNY", 0.5], ["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: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5.
// tests completed
// console output
Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Challenge Information:
Build a Cash Register Project - Build a Cash Register