Sum of all the numbers in the Nth row of the given triangle | Function to return the sum of the nth row elements of the given triangle ; Driver code
function getSum ( n ) { return ( ( n - 1 ) + Math . pow ( n , 2 ) ) ; } var n = 3 ; document . write ( getSum ( n ) ) ;