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 .....
//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;
- }
Test.assertDeepEquals(test(11),33); Test.assertDeepEquals(test(10),23); Test.assertDeepEquals(test(0),0); Test.assertDeepEquals(test(4),3);
function test() {var a = [];for (i=1; i<10; i++){if ((i%3==0) || (i%5==0)){a.push(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);- Test.assertDeepEquals(test(11),33);
- Test.assertDeepEquals(test(10),23);
- Test.assertDeepEquals(test(0),0);
- Test.assertDeepEquals(test(4),3);