I want to print the value that the variable quantity holds in HTML
Here's my JavaScript code
class Ingredient {
constructor (name, dateBought, expiryDate, quantity, expired){
this.name = name;
this.dateBought = dateBought;
this.expiryDate = expiryDate;
this.quantity = quantity;
this.expired = false;
}
isExpired(){
this.expired = true;
}
needReorder(){
console.log(this. name + "need to be reordered")
}
}
let cabbage = ("cabbage", new Date(2003,3,2), 23)
I'm trying to display the quantity in an HTML file like this, so far nothing prints
<script src="inventory.js">
var quantity = cabbage.quantity
</script>
<script>
document.write(quantity)
</script>
I know that there isn't anything wrong with my HTML because this code works perfectly fine
<script>
document.write("write something")
</script>
Thank you in advance :)