Cost of painting n * m grid | Function to return the minimum cost ; Driver Code
function getMinCost ( n , m ) { let cost = ( n - 1 ) * m + ( m - 1 ) * n ; return cost ; } let n = 4 , m = 5 ; document . write ( getMinCost ( n , m ) ) ;