JSFiddle - React, Tailwind, and code Playground
by kalar su
HTML
<p id="myProduct1"></p>
<p id="myProduct2"></p>
JavaScript
function Products(id, name, price, impQty, soldQty, desc){
this.id = id;
this.name = name;
this.price = price;
this.impQty = impQty;
this.soldQty = soldQty;
this.desc = desc;
this.checkAvailability = function(){
return this.impQty - this.soldQty;
}
}
//var cart = [];
var product1 = new Products("001", "iphone10", 1000, 1000, 500);
//cart.push(product1);
var product2 = new Products("002", "iphone6", 500, 100, 8);
//cart.push(product2);
document.getElementById("myProduct1").textContent = cart[0].price;
document.getElementById("myProduct2").textContent = cart[1].name;