I get a weird error with the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles.css" />
<title>Cash Register</title>
</head>
<body>
<h1>Cash Register</h1>
<div class="input-container">
<label for="number-input">Cash:</label>
<input value="" id="cash" />
<br></br>
</div>
<div class="buttons">
<button id="purchase-btn">Purchase</button>
</div>
<div id="change-due"></div>
<script type="text/javascript" href="script.js"></script>
</body>
</html>
* {
margin: 0;
padding: 0;
display: block;
}
h1 {
text-align: center;
margin-bottom: 10px;
}
.purchase-btn {
width: 100px;
height: 60px;
margin-right: 40px;
border-width: 3px;
font-size: 18px;
color:white;
background-color: green;
border-color: green;
}
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]
];
const cash = document.getElementById("cash");
const changeDue = document.getElementById("change-due");
const purchaseBtn = document.getElementById("purchase-btn");
purchaseBtn.addEventListener((cid, cash, price) => {
const currency = [ .01, .05, .10, .25, 1, 5, 10, 20, 100];
let count = [0, 0, 0, 0, 0, 0, 0, 0, 0];
let message = "";
let change = cash - price;
const paid = parseInt(cash.text);
if (change < 0) {
message = "Status : INSUFFICIENT_FUN DS";
}
let index = cid.length;
let zeroes = 0;
while (index >= 0 && change !== 0) {
while (cid[index][1] >= change) {
let denomination = cid[index][0];
let inDrawer = cid[index][1];
let currValue = currency[index];
cid[index][1] -= denomination;
count[index]++;
change -= denomination;
if (cid[index][1] === 0) {
zeroes++;
}
index--;
}
}
if (zeroes === cid.length) {
message = "Status: CLOSED";
}
else {
message = "Status: OPEN";
}
for (let i = count.length; count >= 0; count--) {
message += " " + denomination + ": $" + count[i] * currency[i] + "\n";
}
changeDue.textContent = message;
console.log(message);
});
The error is a very long block of code having to do with the window object, followed by an image of the window with no .css access (The link is in the HTML) then the line âuse strictâ.
Fcc woul not allow me to copy the error because it is in the preview screen. The console window has no information.