Cash Register Project not working

Locally, my cash register seems to work, but apparently no tests are passing. I’d appreciate any help :slight_smile: thanks!

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Cash Register Project</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header> CASH REGISTER PROJECT</header>
  <main>
    <div id="change-due">
      <p id="status" class="hidden"></p>
      <p id="hundred-p" class="hidden"></p>
      <p id="twenty-p" class="hidden">/p>
      <p id="five-p" class="hidden"></p>
      <p id="one-p" class="hidden"></p>
      <p id="quarter-p" class="hidden"></p>
      <p id="dime-p" class="hidden"></p>
      <p id="nickel-p" class="hidden"></p>
      <p id="penny-p" class="hidden"></p>
    </div>
    <label for="cash">Enter cash from customer:</label>
    <input type="number" name="cash" id="cash">
    <button id="purchase-btn">Purchase Item</button>
    <div id="total">Total price: $ </div>
    <div id="available-cash">
      <div id="penny">Pennies: <span>$1.01 </span></div>
      <div id="nickel">Nickels: <span>$2.05 </span></div>
      <div id="dime">Dimes: <span>$3.1 </span></div>
      <div id="quarter">Quarters: <span>$4.25 </span></div>
      <div id="one">Ones: <span>$90 </span></div>
      <div id="five">Fives: <span>$55 </span></div>
      <div id="ten">Tens: <span>$20 </span></div>
      <div id="twenty">Twenties: <span>$60 </span></div>
      <div id="hundred">Hundreds: <span>$100 </span></div>
    </div>
  </main>
<script src="script.js"></script>
</body>
</html>

JAVASCRIPT

let price = 1.87;
let cid = [
  ["PENNY", 1.01],
  ["NICKEL", 2.05],
  ["DIME", 3.1],
  ["QUARTER", 4.25],
  ["ONE", 90],
  ["FIVE", 55],
  ["TEN", 20],
  ["TWENTY", 60],
  ["HUNDRED", 100]
];

const availableCash = document.getElementById("available-cash")
const customerCash = document.getElementById("cash")
const totalPrice = document.getElementById("total")
const purchaseBtn = document.getElementById("purchase-btn")
const changeDue = document.getElementById("change-due")
const statusP = document.getElementById("status")
let arrValues = [];
cid.forEach((arr) => {
  arrValues.push(arr[1])
});
totalPrice.innerText += price
const cashSum = arrValues.reduce((a, b) => a + b).toFixed(2);

const updateResult  = (value, id) => {
  let correctedId = id.toLowerCase().replace(/\s/g, "")
  document.getElementById(`${correctedId}-p`).textContent = `${id}: $${value.toFixed(2).replace(/\.00/g, "")}`
  document.getElementById(`${correctedId}-p`).style.display = "block"
  }

purchaseBtn.addEventListener("click", () => {
  let customerCashValue = parseFloat(customerCash.value).toFixed(2);
  let changeToCalculate = (customerCashValue - price).toFixed(2);
  if (customerCashValue < price) {
    alert("Customer does not have enough money to purchase the item");
  } else if (customerCashValue == price) {
    changeDue.textContent = "No change due - customer paid with exact cash"
    } else if (customerCashValue == cashSum) {
      changeCalculator(changeToCalculate, customerCashValue)
    statusP.style.display = "block";
    statusP.innerText = "Status: CLOSED";
  } else {
    changeCalculator(changeToCalculate, customerCashValue)
  }
}
)


const checkInsufficientFunds = (changeToCalculate, cashSum) => {
  if (cashSum < changeToCalculate) { 
    statusP.innerText = "Status: INSUFFICIENT_FUNDS"
    statusP.style.display = "block";
  }
}

const changeCalculator = (changeToCalculate, customerCashValue) => {
  checkInsufficientFunds(changeToCalculate);
  statusP.innerText = "Status: OPEN";
  statusP.style.display = "block";
  while (changeToCalculate > 0) {
    if (changeToCalculate >= 100 && cid[8][1]) {
      const multiplier = Math.floor(changeToCalculate/ 100);
      const value = 100 * multiplier
      customerCashValue -= (100 * multiplier);
      changeToCalculate -= (100 * multiplier);
      cid[8][1] -= (100 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[8][0])
    }
    else if (changeToCalculate >= 20 && cid[7][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 20);
      const value = 20 * multiplier;
      customerCashValue -= (20 * multiplier);
      changeToCalculate -= (20 * multiplier);
      cid[7][1] -= (20 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[7][0])
    }
    else if (changeToCalculate >= 10 && cid[6][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 10);
      const value = 10 * multiplier;
      customerCashValue -= (10 * multiplier);
      changeToCalculate -= (10 * multiplier);
      cid[6][1] -= (10 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[6][0])
    } 
    else if (changeToCalculate >= 5 && cid[5][1] > 0) {
      const multiplier = Math.floor(((changeToCalculate/ 5)));
      const value = 5 * multiplier;
      customerCashValue -= (5 * multiplier);
      changeToCalculate -= (5 * multiplier);
      cid[5][1] -= (5 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[5][0])
    }
    else if (changeToCalculate >= 1 && cid[4][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 1);
      const value = 1 * multiplier;
      customerCashValue -= (1 * multiplier);
      changeToCalculate -= (1 * multiplier);
      cid[4][1] -= (1 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[4][0])
      
    }
    else if (changeToCalculate >= 0.25 && cid[3][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 0.25);
      const value = 0.25 * multiplier;
      customerCashValue -= (0.25 * multiplier);
      changeToCalculate -= (0.25 * multiplier);
      cid[3][1] -= (0.25 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[3][0])
      
    } 
    else if (changeToCalculate >= 0.1 && cid[2][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 0.1);
      const value = 0.1 * multiplier;
      customerCashValue -= (0.1 * multiplier);
      changeToCalculate -= (0.1 * multiplier);
      cid[2][1] -= (0.1 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[2][0])
      
    } else if (changeToCalculate >= 0.05 && cid[1][1] > 0) {
      const multiplier = (changeToCalculate/ 0.05);
      const value = 0.05 * multiplier;
      customerCashValue -= (0.05 * multiplier);
      changeToCalculate -= (0.05 * multiplier);
      cid[1][1] -= (0.05 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[1][0])
      
    } else if (changeToCalculate >= 0.01 && cid[0][1] > 0) {
      const multiplier = (changeToCalculate / 0.01);
      const value = 0.01 * multiplier;
      customerCashValue -= (0.01 * multiplier);
      changeToCalculate -= (0.01 * multiplier);
      cid[0][1] -= (0.01 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[0][0])
    }
  }
}

const updateCashInRegister = cid => {
  cid.forEach((arr) => {
    let id = arr[0].toLowerCase().replace(/\s/g, "")
    document.querySelector(`#${id} span`).innerText = `$${arr[1].toFixed(2).replace(/\.00/g, "")}`;
  });
  console.log(cid)
}

You need to get rid of these global variables. You can’t use other CID contents in your functions if you don’t

1 Like

Thanks for replying, Jeremy!

Let me try and see :slight_smile:

1 Like

Even the cashSum variable?

Each function should accept themdata it needs as arguments and pass out results via ‘return’

Thanks for helping me out!

I changed my script to:

let price = 1.87;
let cid = [
  ["PENNY", 1.01],
  ["NICKEL", 2.05],
  ["DIME", 3.1],
  ["QUARTER", 4.25],
  ["ONE", 90],
  ["FIVE", 55],
  ["TEN", 20],
  ["TWENTY", 60],
  ["HUNDRED", 100]
];

const availableCash = document.getElementById("available-cash")
const customerCash = document.getElementById("cash")
const totalPrice = document.getElementById("total")
const purchaseBtn = document.getElementById("purchase-btn")
const changeDue = document.getElementById("change-due")
const statusP = document.getElementById("status")

const setPrice = (price) => {
  totalPrice.innerText += price;
}
setPrice(price);

const updateResult  = (value, id) => {
  let correctedId = id.toLowerCase().replace(/\s/g, "")
  document.getElementById(`${correctedId}-p`).textContent = `${id}: $${value.toFixed(2).replace(/\.00/g, "")}`
  document.getElementById(`${correctedId}-p`).style.display = "block"
  }

purchaseBtn.addEventListener("click", () => {
  let arrValues = [];
  cid.forEach((arr) => {
    arrValues.push(arr[1])
    });
  let cashSum = arrValues.reduce((a, b) => a + b).toFixed(2);
  let customerCashValue = parseFloat(customerCash.value).toFixed(2);
  let changeToCalculate = (customerCashValue - price).toFixed(2);
  if (customerCashValue < price) {
    alert("Customer does not have enough money to purchase the item");
  } else if (customerCashValue == price) {
    changeDue.textContent = "No change due - customer paid with exact cash"
  } else if (customerCashValue == cashSum) {  
    statusP.style.display = "block";
    statusP.innerText = "Status: CLOSED";
    changeCalculator(changeToCalculate, customerCashValue)
  } else {
    return changeCalculator(changeToCalculate, customerCashValue)
  }
}
)

const checkInsufficientFunds = (changeToCalculate, cashSum) => {
  if (cashSum < changeToCalculate) { 
    statusP.innerText = "Status: INSUFFICIENT_FUNDS"
    statusP.style.display = "block";
  }
  return
}

const changeCalculator = (changeToCalculate, customerCashValue) => {
  let arrValues = [];
  cid.forEach((arr) => {
  arrValues.push(arr[1])
  });
  let cashSum = arrValues.reduce((a, b) => a + b).toFixed(2);
  checkInsufficientFunds(changeToCalculate, cashSum);
  statusP.innerText = "Status: OPEN";
  statusP.style.display = "block";
  while (changeToCalculate > 0) {
    if (changeToCalculate >= 100 && cid[8][1]) {
      const multiplier = Math.floor(changeToCalculate/ 100);
      const value = 100 * multiplier
      customerCashValue -= (100 * multiplier);
      changeToCalculate -= (100 * multiplier);
      cid[8][1] -= (100 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[8][0])
    }
    else if (changeToCalculate >= 20 && cid[7][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 20);
      const value = 20 * multiplier;
      customerCashValue -= (20 * multiplier);
      changeToCalculate -= (20 * multiplier);
      cid[7][1] -= (20 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[7][0])
    }
    else if (changeToCalculate >= 10 && cid[6][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 10);
      const value = 10 * multiplier;
      customerCashValue -= (10 * multiplier);
      changeToCalculate -= (10 * multiplier);
      cid[6][1] -= (10 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[6][0])
    } 
    else if (changeToCalculate >= 5 && cid[5][1] > 0) {
      const multiplier = Math.floor(((changeToCalculate/ 5)));
      const value = 5 * multiplier;
      customerCashValue -= (5 * multiplier);
      changeToCalculate -= (5 * multiplier);
      cid[5][1] -= (5 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[5][0])
    }
    else if (changeToCalculate >= 1 && cid[4][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 1);
      const value = 1 * multiplier;
      customerCashValue -= (1 * multiplier);
      changeToCalculate -= (1 * multiplier);
      cid[4][1] -= (1 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[4][0])
      
    }
    else if (changeToCalculate >= 0.25 && cid[3][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 0.25);
      const value = 0.25 * multiplier;
      customerCashValue -= (0.25 * multiplier);
      changeToCalculate -= (0.25 * multiplier);
      cid[3][1] -= (0.25 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[3][0])
      
    } 
    else if (changeToCalculate >= 0.1 && cid[2][1] > 0) {
      const multiplier = Math.floor(changeToCalculate/ 0.1);
      const value = 0.1 * multiplier;
      customerCashValue -= (0.1 * multiplier);
      changeToCalculate -= (0.1 * multiplier);
      cid[2][1] -= (0.1 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[2][0])
      
    } else if (changeToCalculate >= 0.05 && cid[1][1] > 0) {
      const multiplier = (changeToCalculate/ 0.05);
      const value = 0.05 * multiplier;
      customerCashValue -= (0.05 * multiplier);
      changeToCalculate -= (0.05 * multiplier);
      cid[1][1] -= (0.05 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[1][0])
      
    } else if (changeToCalculate >= 0.01 && cid[0][1] > 0) {
      const multiplier = (changeToCalculate / 0.01);
      const value = 0.01 * multiplier;
      customerCashValue -= (0.01 * multiplier);
      changeToCalculate -= (0.01 * multiplier);
      cid[0][1] -= (0.01 * multiplier);
      updateCashInRegister(cid);
      updateResult(value, cid[0][0])
    }
  }
}

const updateCashInRegister = cid => {
  cid.forEach((arr) => {
    let id = arr[0].toLowerCase().replace(/\s/g, "")
    document.querySelector(`#${id} span`).innerText = `$${arr[1].toFixed(2).replace(/\.00/g, "")}`;
  });
  return
}

However, tests do not pass

This is a screenshot of my code output when I put $2 for a 1.87 price

I think I will trying redoing it from scratch, since I really don’t know what’s happening

If you want to manually attempt test case, add reassignment of the cid and price at the end of code, instead of changing values with which they are declared. That’s more accurate how it’s done when tests are running.

2 Likes

Thanks for that tip!

1 Like

Hello, everyone! I completely rewrote my code and it is now way better optimized. However, the tests still don’t pass despite code working on VSCode. Please help :frowning:
I really don’t knwo what is going on.

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Cash Register Project</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header> CASH REGISTER PROJECT</header>
  <main>
    <div id="change-due">
      <p id="status" class="hidden">Status: <span> </span></p>
      <p id="onehundred-p" class="hidden">ONE HUNDRED: <span></span></p>
      <p id="twenty-p" class="hidden">TWENTY: <span></span></p>
      <p id="ten-p" class="hidden">TEN: <span> </span></p>
      <p id="five-p" class="hidden">FIVE: <span> </span></p>
      <p id="one-p" class="hidden">ONE: <span> </span></p>
      <p id="quarter-p" class="hidden">QUARTER: <span></span></p>
      <p id="dime-p" class="hidden">DIME: <span></span></p>
      <p id="nickel-p" class="hidden">NICKEL: <span></span></p>
      <p id="penny-p" class="hidden">PENNY: <span></span></p>
    </div>
    <label for="cash">Enter cash from customer:</label>
    <input type="number" name="cash" id="cash">
    <button id="purchase-btn">Purchase Item</button>
    <div id="total">Total price: $ </div>
    <div id="available-cash">
      <div id="penny">Pennies: <span>$1.01 </span></div>
      <div id="nickel">Nickels: <span>$2.05 </span></div>
      <div id="dime">Dimes: <span>$3.1 </span></div>
      <div id="quarter">Quarters: <span>$4.25 </span></div>
      <div id="one">Ones: <span>$90 </span></div>
      <div id="five">Fives: <span>$55 </span></div>
      <div id="ten">Tens: <span>$20 </span></div>
      <div id="twenty">Twenties: <span>$60 </span></div>
      <div id="onehundred">Hundreds: <span>$100 </span></div>
    </div>
  </main>
<script src="script.js"></script>
</body>
</html>

JAVASCRIPT

let price = 1.87;
let cid = [
  ["PENNY", 1.01],
  ["NICKEL", 2.05],
  ["DIME", 3.1],
  ["QUARTER", 4.25],
  ["ONE", 90],
  ["FIVE", 55],
  ["TEN", 20],
  ["TWENTY", 60],
  ["ONE HUNDRED", 100]
];


//constant definitions
const availableCash = document.getElementById("available-cash")
const customerCash = document.getElementById("cash")
const totalPrice = document.getElementById("total")
const purchaseBtn = document.getElementById("purchase-btn")
const changeDue = document.getElementById("change-due")
const statusP = document.getElementById("status")

const setPrice = (price) => {
  totalPrice.innerText += price;
}
setPrice(price);

//click event listener on purchase button
purchaseBtn.addEventListener("click", () => { 
  let cash = parseFloat(customerCash.value);
  if (cash < price) {
    alert("Customer does not have enough money to purchase the item")
    return
  } else if (cash === price) {
    changeDue.innerText = "No change due - customer paid with exact cash"
  } else {
    return calculateChange(cash, price)
  }
})

//check if register doesn't have enough cash
const insufficientFunds = cash => {
  let totalCash = cid.map((arr) => arr[1]).reduce((a, b) => a + b, 0).toFixed(2)
  if (totalCash < cash) {
    statusP.innerText = "Status: INSUFFICIENT_FUNDS"
    statusP.style.display = "block";
    return true
  } else {
    return false
  }
}

//calculateChange logic
const calculateChange = (cash, price) => {
  if (insufficientFunds(cash));
  cid = cid.reverse();
  let sumTotalArr = [
    ["ONE HUNDRED", 0],
    ["TWENTY", 0],
    ["TEN", 0],
    ["FIVE", 0],
    ["ONE", 0],
    ["QUARTER", 0],
    ["DIME", 0],
    ["NICKEL", 0],
    ["PENNY", 0]
  ]
  let change = parseFloat((cash - price).toFixed(2));
  let equivalences = [100, 20, 10, 5, 1, 0.25, 0.1, 0.05, 0.01];
  while (Number(change.toFixed(2)) > 0) {
    for (let i = 0; i < cid.length; i++) {
      let num = parseFloat(equivalences[i].toFixed(2));
        if (change >= num && cid[i][1] > 0) {
        change -= num;
        cid[i][1] -= num;
        sumTotalArr[i][1] += num;
        change = Number(change.toFixed(2));
      } 
    } 
  } updateResultDisplay(cid.reverse())
  updateChangeDisplay(sumTotalArr.reverse())
  
}

const updateResultDisplay = (arr) => {
  if (arr.every((subArr) => subArr[1] === 0)) {
    statusP.innerText = "Status: ClOSED"
    statusP.style.display = "block";
    arr.forEach((subArr) => {
      let id = subArr[0];
      let correctedId = id.toLowerCase().replace(/\s/g, "");
      let paragraph = document.querySelector(`#${correctedId} span`);
      paragraph.innerText = `$${Number(subArr[1].toFixed(2))}`;
  })} else {
  arr.forEach((subArr) => {
    let id = subArr[0];
    let correctedId = id.toLowerCase().replace(/\s/g, "");
    let paragraph = document.querySelector(`#${correctedId} span`);
    paragraph.innerText = `$${Number(subArr[1].toFixed(2))}`;
  })}
}
const updateChangeDisplay = arr => {
  let valuesArr = arr.filter((arr) => arr[1] > 0);
  valuesArr.forEach((subArr) => {
    let id = subArr[0];
    let correctedId = id.toLowerCase().replace(/\s/g, "");
    let span = document.querySelector(`#${correctedId}-p span`);
    span.textContent = `$${Number(subArr[1].toFixed(2))}`;
    let paragraph = document.querySelector(`#${correctedId}-p.hidden`);
    paragraph.style.display = "block";
    statusP.innerText = "Status: OPEN"
    statusP.style.display = "block";
  })
}

I have no global variables excepting for price and cid array

I changed my script a little bit, but still doesn’t work:

let price = 1.87;
let cid = [
  ["PENNY", 1.01],
  ["NICKEL", 2.05],
  ["DIME", 3.1],
  ["QUARTER", 4.25],
  ["ONE", 90],
  ["FIVE", 55],
  ["TEN", 20],
  ["TWENTY", 60],
  ["ONE HUNDRED", 100]
];

//constant definitions
const availableCash = document.getElementById("available-cash")
const customerCash = document.getElementById("cash")
const totalPrice = document.getElementById("total")
const purchaseBtn = document.getElementById("purchase-btn")
const changeDue = document.getElementById("change-due")
const statusP = document.getElementById("status")

const setPrice = (price) => {
  totalPrice.innerText += price;
}
setPrice(price);

//click event listener on purchase button
purchaseBtn.addEventListener("click", () => { 
  let cash = parseFloat(customerCash.value);
  if (cash < price) {
    alert("Customer does not have enough money to purchase the item")
    return
  } else if (cash === price) {
    changeDue.innerText = "No change due - customer paid with exact cash"
  } else {
    return calculateChange(cash, price)
  }
})

//check if register doesn't have enough cash
const insufficientFunds = cash => {
  let totalCash = cid.map((arr) => arr[1]).reduce((a, b) => a + b, 0).toFixed(2)
  if (totalCash < cash) {
    statusP.innerText = "Status: INSUFFICIENT_FUNDS"
    statusP.style.display = "block";
    return true
  } else {
    return false
  }
}

//calculateChange logic
const calculateChange = (cash, price) => {
  if (insufficientFunds(cash));
  cid = cid.reverse();
  let sumTotalArr = [
    ["ONE HUNDRED", 0],
    ["TWENTY", 0],
    ["TEN", 0],
    ["FIVE", 0],
    ["ONE", 0],
    ["QUARTER", 0],
    ["DIME", 0],
    ["NICKEL", 0],
    ["PENNY", 0]
  ]
  let change = parseFloat((cash - price).toFixed(2));
  let equivalences = [100, 20, 10, 5, 1, 0.25, 0.1, 0.05, 0.01];
  while (Number(change.toFixed(2)) > 0) {
    for (let i = 0; i < cid.length; i++) {
      let num = parseFloat(equivalences[i].toFixed(2));
        while (change >= num && cid[i][1] > 0) {
        change -= num;
        cid[i][1] -= num;
        sumTotalArr[i][1] += num;
        change = Number(change.toFixed(2));
        console.log(change)
      } 
    } 
  } updateResultDisplay(cid.reverse())
  updateChangeDisplay(sumTotalArr.reverse())
  
}

const updateResultDisplay = (arr) => {
  if (arr.every((subArr) => subArr[1] === 0)) {
    statusP.innerText = "Status: ClOSED"
    statusP.style.display = "block";
    arr.forEach((subArr) => {
      let id = subArr[0];
      let correctedId = id.toLowerCase().replace(/\s/g, "");
      let paragraph = document.querySelector(`#${correctedId} span`);
      paragraph.innerText = `$${Number(subArr[1].toFixed(2))}`;
  })} else {
  arr.forEach((subArr) => {
    let id = subArr[0];
    let correctedId = id.toLowerCase().replace(/\s/g, "");
    let paragraph = document.querySelector(`#${correctedId} span`);
    paragraph.innerText = `$${Number(subArr[1].toFixed(2))}`;
  })}
}
const updateChangeDisplay = arr => {
  let valuesArr = arr.filter((arr) => arr[1] > 0);
  valuesArr.forEach((subArr) => {
    let id = subArr[0];
    let correctedId = id.toLowerCase().replace(/\s/g, "");
    let span = document.querySelector(`#${correctedId}-p span`);
    span.textContent = `$${Number(subArr[1].toFixed(2))}`;
    let paragraph = document.querySelector(`#${correctedId}-p.hidden`);
    paragraph.style.display = "block";
    statusP.innerText = "Status: OPEN"
    statusP.style.display = "block";
  })
}

You’re putting way, way more into the change-due element than the instructions ask for.

For example, for the first test case you have

Status: OPEN

ONE HUNDRED:

TWENTY:

TEN:

FIVE:

ONE:

QUARTER: $0.5

DIME:

NICKEL:

PENNY: 

and not

Status: OPEN QUARTER: $0.5
1 Like

Really?

I don’t understand why . Let me check

It doesn’t allow me to reply anymore

      <p id="onehundred-p" class="hidden">ONE HUNDRED: <span></span></p>
      <p id="twenty-p" class="hidden">TWENTY: <span></span></p>
      <p id="ten-p" class="hidden">TEN: <span> </span></p>
      <p id="five-p" class="hidden">FIVE: <span> </span></p>
      <p id="one-p" class="hidden">ONE: <span> </span></p>
      <p id="quarter-p" class="hidden">QUARTER: <span></span></p>
      <p id="dime-p" class="hidden">DIME: <span></span></p>
      <p id="nickel-p" class="hidden">NICKEL: <span></span></p>
      <p id="penny-p" class="hidden">PENNY: <span></span></p>

none of this was in the instructions

1 Like

THANK YOU SO MUCH!!

You were right, once I removed the redundant HTML code, the tests started to pass, and I could tweak those who weren’t passing.

I passed all tests now!!

You’re the best, Jeremy. Thanks :star_struck:

1 Like

Nice work!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.