Problem 1: Multiples of 3 and 5 why is each number is printed separately?

Why doesn’t this code push the numbers to the same array ?
Each number is printed separately

I think the array is reinitialized to an empty array every time the loop loops (line 3).

I tried to put it inside the if statement but it gave me the same result, do you know how can i fix this ?

It would really help if you post your actual code instead of pictures.

But yes, if arr is inside of the loop, then you re-initalize it on every loop iteration.

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