Estimating the profit

THE CHALLENGE

This is my improved version of "calculate the profit" challenge. In this app, you are asked to enter three values, and the app will give you an estimation of your profit.

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

        
          // Estimate the Profit

          function profit(costPrice, sellPrice, inventory) {
            let totalSales = inventory * sellPrice;
            let totalCost = inventory * costPrice;
            let profit = totalSales - totalCost;
            print("Your estimated Profit/Loss is " + profit)
          
            // to show the result on your console use
            // console.log("Your Profit/Loss is " + profit)
          };
          profit(
            prompt("How much is a unit cost you?"),
            prompt("What is the selling price of a unit?"),
            prompt("How many units are you predicting to sell?")
          );
        
      

THE EXECUTION RESULT

        
      

the built-in console was provided by my amazing trainer Sorin. PrismJS plug-in is used to show the code