Sum of Series ( n ^ 2 | function that calculate the sum of the nth series ; using formula of the nth term ; Driver code
function sum_series ( n ) { let nSquare = n * n ; return nSquare * ( nSquare - 1 ) / 4 ; } let n = 2 ; document . write ( sum_series ( n ) ) ;