.Write a function called multiplyBy10 that takes two numbers as parameters and returns the first number multiplied by 10 the amount of times specified by the second number

multiplyBy10(4, 3) → 4000

multiplyBy10(5, 2) → 500

.Write a function called multiplyBy10 that takes two numbers as parameters and returns the first number multiplied by 10 the amount of times specified by the second number

multiplyBy10(4, 3) → 4000

multiplyBy10(5, 2) → 500

First thing I did when seeing this was trying to figure it out mathematically which took me too much time for a simple problem , so instead I decided to use string manipulation in a simple for loop. The challenge is essentially making us add a 0 for an x amount of times. Thus, that is what we do in the for loop. Then finally take the result and multiply it by the first parameter.

```
function multiplyBy10(x, y) {
let string = "1";
for (let i = 1; i <= y; i++) {
string += "0";
}
return x * string;
}
```

So what is your problem?

You need to define a function and use a for-loop or just raise the power of 10.

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