We are required to write a JavaScript function that takes in two numbers, say m and n, and it returns an array of first n multiples of m.
Therefore, let’s write the code for this function −
Example
The code for this will be −
const num1 = 4; const num2 = 6; const multiples = (num1, num2) => { const res = []; for(let i = num1; i <= num1 * num2; i += num1){ res.push(i); }; return res; }; console.log(multiples(num1, num2));
Output
The output in the console will be −
[ 4, 8, 12, 16, 20, 24 ]