Sum of the count of number of adjacent squares in an M X N grid | function to calculate the sum of all cells adjacent value ; Driver program to test above
function sum ( m , n ) { return 8 * m * n - 6 * m - 6 * n + 4 ; } var m = 3 , n = 2 ; document . write ( sum ( m , n ) ) ;