JSFiddle - React, Tailwind, and code Playground
HTML
<button>
Click me and go Shopping!
</button>
<div id="result" ></div>
CSS
button {
font-size: 1em;
padding: 3px;
}
JavaScript
var buy = ["milk"];
var eggs = 6;
$("button").click(function() {
for(i = 0; i < buy.length; i++){
buyProduct(buy[i]);
if (eggs > 0){
buyProduct(eggs);
}
}
$("button").hide();
});
function buyProduct(product){
$("#result").append("<p>Bought: " + product +"</p>");
}