He gives the answers however he tells me that he is wrong. What am I doing wrong?

Tell us what’s happening:

Your code so far


function multiplesOf3and5(number) {
// Good luck!
let sum = 0;
for(i=1; i<number;i++){
  if(i%3==0 || i%5==0){
    sum = sum+i;
  }
}
return sum ;
}

multiplesOf3and5(1000);

Your browser information:

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

Challenge: Problem 1: Multiples of 3 and 5

Link to the challenge:
https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/problem-1-multiples-of-3-and-5

Hello jucarlospm, welcome to the forum!

When I copy/paste your code into the challenge, I get the error "ReferenceError: i is not defined". Are you getting this error?

If so, then you just need to figure out why i is not defined. Remember, you have to use let, var, or const to declare a variable.

1 Like

Thank you very much I miss declare the variable i

for(let i=1; i<number;i++){