Project Euler Problem 1 Test Case Not Working

Hello,
I am trying to complete the first problem for Project Euler, but the test cases are not working. However, if I perform my own tests they return the desired answers. Can anyone help me fix this? I logged out of my account and closed/reopened the browser and I’m still having the same issue. Thanks!

function multiplesOf3and5(number) {

var sum = 0;
var i = 0;
for (i; i < number; i++) {
  if (i%3 == 0 || i%5 == 0) {
    sum = i + sum;
  }
}
  return true;
}

multiplesOf3and5(1000);

Please post the link to the Challenge.

You should not be using var. let or const is recommend.

Declaring the loop iteration variable outside of the loop head is strange.

Why are you returning this?

  1. Ok, I originally had let, but wondered if that was the issue.
  2. Good catch, fixed that as well.
  3. The return statement was already there before I began coding.

Thank you for your quick help!

So right now youlr function says that the sum is always going to be the boolean literal ‘true’

Ahhhhhh thank you so much! I got it now :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.