Sum of squares of first n natural numbers | Return the sum of square of first n natural numbers ; Iterate i from 1 and n finding square of i and add to sum . ; Driven Program
function squaresum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum ; } let n = 4 ; document . write ( squaresum ( n ) + " " ) ;