function multiples(x, n) {
let m = [];
for (let i=1; i<= n; i++){
x *= n[i];
m.push(x);
}
return m;
}
I don’t understand why my function is not working. I Need help please.
>Solution :
I think this is what you need.
function multiples(x, n) {
let m = [];
for (let i=1; i<= n; i++){
m.push(x*i);
}
return m;
}
The thing you were not achieving your desired output is due to the fact you are treating n as an array which is not. You just need to multiply the number x with i (which should be increasing until it becomes equal to n) and push it to the array.