Calculate the Profit
THE CHALLENGE
Create a function that takes a number as its only argument and returns true if it's less than or equal to zero, otherwise return false.
Please notice that I use print in the code instead of console.log to show the result in my built-in console below. However, you should use console.log to
show the result in your normal console
THE CODE
// week 4, day 2, challange 2 Objects
// Calculate the Profit
function profit(costPrice, sellPrice, inventory) {
let totalSales = inventory * sellPrice;
let totalCost = inventory * costPrice;
let profit = totalSales - totalCost;
print("Your Profit/Loss is " + profit)
// to show the result on your console use
// console.log("Your Profit/Loss is " + profit)
};
profit(32.67, 45.00, 1200);
profit(225.89, 550.00, 100);
profit(2.77, 7.95, 8500);
THE EXECUTION RESULT