Ad

i know it's too late to reply ...but as said in the previous comment your Code is fine you just need some little changes..and because i am a bad explainer i am just going to show my simple version of the code .....

Code
Diff
  • //if you have any Suggestion or noticed a mistake in my code ...tell me...i would need that...
    function test(n) {
      var sum=0;
      for (i=1; i<n; i++){
        if ((i%3==0) || (i%5==0)){
        sum+=i;
        }
      }
       return sum;
    }
    • function test() {
    • var a = [];
    • for (i=1; i<10; i++){
    • //if you have any Suggestion or noticed a mistake in my code ...tell me...i would need that...
    • function test(n) {
    • var sum=0;
    • for (i=1; i<n; i++){
    • if ((i%3==0) || (i%5==0)){
    • a.push(i);
    • sum+=i;
    • }
    • }
    • return a;
    • }
    • function sum(number){
    • var sum= 0;
    • for(i=0; i<number.length; i++){
    • sum += number[i];
    • }
    • return sum;
    • }
    • var ab = test();
    • var abc = sum(ab);
    • console.log(abc);
    • return sum;
    • }