Program to calculate Profit Or Loss | Function to calculate Profit . ; Function to calculate Loss . ; Driver Code .
function Profit ( costPrice , sellingPrice ) { let profit = ( sellingPrice - costPrice ) ; return profit ; } function Loss ( costPrice , ellingPrice ) { let Loss = ( costPrice - sellingPrice ) ; return Loss ; } let costPrice = 1500 , sellingPrice = 2000 ; if ( sellingPrice == costPrice ) document . write ( " " ) ; else if ( sellingPrice > costPrice ) document . write ( Profit ( costPrice , sellingPrice ) + " " ) ; else document . write ( Loss ( costPrice , sellingPrice ) + " " ) ;