js unit four operators and discount calculation in a real-life projects.
// var num1 = 7;
// var num2 = 4;
// console.log(num1 + num2);
// console.log(num1 - num2);
// console.log(num1 * num2);
// console.log(num1 / num2);
// console.log(num1 % num2);
// console.log(num1 > num2);
// D = (L - S)/ L * 100
// a + ((b * c) / d )* e
var selling_price = 199;
var listing_price = 799;
var discount_percent = ((listing_price - selling_price) / listing_price) * 100;
console.log("Discount precentage is :" + discount_percent + "% off");
display_discount_percentage = Math.round(discount_percent);
console.log("Discount precentage is :" + display_discount_percentage + "% off");
var result = listing_price > selling_price;console.log(result);//If we want to know the type of the result or any data_types then we can use typeofkeywordThe output of these :console.log(typeof(result));
The discount percentage is:75.09386733416771% off
The discount percentage is:75% off
true
boolean
No comments:
Post a Comment