I'm looking to answer the question, but most important to understand where I did it wrong and why. In a certain way to learn how to do it.
So, the question is:
We've already declared a variable for you in the editor called number to which the value 42 was assigned. Use a for loop to go through all numbers from number up to 50 (both inclusive), and check if they are multiples of 3. If they are, print them.
And I got to a point that I print to the console and I get the answer I want: 42, 45, 48.
But the console still gives me an error:
Remember the remainder operator? It might be of help to check if a number is a multiple of 3.
This is my code:
var number = 42;
var dividedbyThree = [];
for (var number = 42; number <= 50; number++) {
if (number % 3 == dividedbyThree) {
console.log(number);
}
}
What am I doing wrong?