This question already has an answer here:
- The 3 different equals 5 answers
The is the function I have created:
function profit_calculation() {
var product_profit = document.getElementById("profit").value;
var int_product_profit = parseInt(product_profit);
var product_cost = document.getElementById("cost").value;
var int_product_cost = parseInt(product_cost);
var profit_added_price = int_product_cost + int_product_profit;
var profit_added_price_per = int_product_profit/int_product_cost*100;
var profit_check = product_profit.includes("%");
if (profit_check = true){
document.getElementById("price").value= profit_added_price_per;
}else{
document.getElementById("price").value= profit_added_price;
}
}
I was working on this but it only runs the function with in the if statement the function under else is totally not working. Please see if anything wrong I have done here. Thanks
Aucun commentaire:
Enregistrer un commentaire