re: Project Euler #1 - Multiples of 3 and 5 VIEW POST

FULL DISCUSSION
 

Here it is ¯\_(ツ)_/¯
I'm looking forward for feedbacks

let sum = 0,                                        
    i = 0

  for (i = 0; i < 1000; i++) {
    if (i % 3 === 0 || i % 5 === 0) sum += i
  }

console.log('The sum is %d', sum)
 

Smallest nitpicking ever: declare i inside the for loop.

for (let i = 0; i < 1000; i++)

It will prevent it from leaking outside the loop.

 

I wouldn't even call that nitpicking, that is solid best practice advice to avoid memory leaks.

code of conduct - report abuse