Multiples of 3 or 5

    0

    0

    The code defines a function that takes an input of number as a parameter and returns the sum of all of the i's that are divisible by 3 or 5.

    function solution(number){
    
      let sum = 0;    for(let i=1; i<number; i++) {        
        if(i % 3 === 0 || i % 5 === 0){            
          sum += i;        
        }    
      }    
      return sum;
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.