Added if(cost === "") & if(profit === "")

With
document.write
console.log