Dividing first number in function by second

Hello, need some kind of advise or a direction.

I need to write a function, that accepts two arguments (numbers), for example a and b. I need to write a loop that prints all numbers from 0 to a that can be divided by b.

This is what I have so far:

function myFunction(a, b) {
    let number = 0;
    for(var i = 1; i <= a; i += 1) {
    number = i;
}
    //so far, I am just printing all the numbers from 0 to 10
}
myFunction(10, 3);

The result should be like this:
0
3
6
9

Thanks!!

Well, all of those numbers cannot be divided by 3 (in this case).

We can divide them by themselves? Or maybe I am missing something :slight_smile:

Yes, we are getting respectfully whole numbers (1,2,3). Is that correct?

As I understand, because the rest of the numbers will get remainders, like 3,33333

Hello! so I was trying to break the code into smaller bits, and here is what I am starting with:

function myFunction(a, n) {
    for (let i = 0; i <= a; i++) {
        let results = i / n;
        console.log(results);
    }
}
myFunction(10, 3);

Basically I want to loop through, but I am missing a step, as I am trying to get atleast the 0, 1.333,2.666, 3 as the result. Can you advise what am I missing?

Thank you so much!

WOW! That worked. This is amazing! Let me show you my current code.

function displayEvenlyDivisibleNumbers(a, b) {
  for (let number = 0; number <= a; number++) {
    if (!(number % b)) {
      console.log(number);
    }
  }
}
displayEvenlyDivisibleNumbers(10, 3);

I am quite new to Javascript, but decided to learn it a bit differently. I want to find useful practice example, such as this one and try to solve it on paper and then find how to turn it to code.

Anyway! I appreciate your help! You are great!

// simply do this
function myFunction(a, b) {
    for(var i = b; i <= a; i += b) {
         console.log(i);
    }
}

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.