showing results for - "javascript multiples of 3 and 5"
Anna
06 Feb 2018
1function sumOfMultiples(number) {    
2  let sum = 0;    for(let i=1; i<number; i++) {        
3    if(i % 3 === 0 || i % 5 === 0){            
4      sum += i;        
5    }    
6  }    
7  return sum;
8}
9
10sumOfMultiples(10); // returns 23 as 3 + 5 + 6 + 9 = 23
11sumOfMultiples(15); // returns 45 as 3 + 5 + 6 + 9 + 10 + 12 = 45