Sum of numbers using for loop in javascript