Javascript Flow Control Excercise 8 issue

I cannot get the same results as Mosh with the identical code. It seems the if statement is being ignored. Below is code with added console.log lines that helped me understand what is failing. The question is why is the 'if statement" failing?

"console.log(sumLimits(7));

function sumLimits(limit) {
let sum = 0;

for (let i = 0; i <= limit; i++) {
    if ((i % 3 === 0) || (i % 5 === 0))
        console.log(i)
		sum += i
		console.log('sum ', sum);
}

return sum;

}
"

Output to Console is as follows:
"
[Running] node “e:\Java-Node\lessons-sumlimit.js”

0
sum 0
sum 1
sum 3
3
sum 6
sum 10
5
sum 15
6
sum 21
sum 28
28
"

Since you don’t refere to a lesson or say what result you would expect I can only guess from your indentation that you want the sum statements to be executed in the true branch of the second if. If so, you need to wrap the three lines below the if with curly brackets for them to be treated as a code block. Currently only console.log(i) gets executed if the condition of the if statement is true. The addition and the second log are executed unconditionally since they are outside the if statement. You can easily see that when you let your IDE reformat the code to reflect the logical structure.

Hi Sam,

Lesson # was truncated from title!

VS code was altering format of code, and being a Noob to JS, I missed the requirement of { } to keep code treated as a block.

Thanks for the assistance!!

Fausto