Project Euler: Problem 1: Multiples of 3 and 5

Tell us what’s happening:

Every condition has been accomplished except for the third:
multiplesOf3and5(1000) should return 233168).
What is wrong with my code?

Your code so far

function multiplesOf3and5(number) {
let sum = 0;
for (number; number >= 0; number--) {
 (number % 3 === 0 || number % 5 === 0) && (sum += number);
return sum;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36.

Challenge: Problem 1: Multiples of 3 and 5

Link to the challenge:

The instruction states:

Find the sum of all the multiples of 3 or 5 below the provided parameter value number .

The key word here is below. Your current algorithm includes the number passed to the function in the sum, when it should not.

1 Like

You were right! I did it already. Thank you so much Randell.