Sum of integers upto N with given unit digit | Function to return the required sum ; Driver code
function getSum ( n , d ) { let sum = 0 ; while ( d <= n ) { sum += d ; d += 10 ; } return sum ; } let n = 30 ; let d = 3 ; document . write ( getSum ( n , d ) ) ;