I´m a beginner in JS. I’m trying to write a function that would raise an array for particular exponent. For example, that the function raiser([2, 5, 10], 2); would output 4, 25, 100. I tried to write this function:
function raiser(numbers, exponent) {
for (let i = 0; i < numbers.length; i++) {
return console.log(Math.pow(numbers[i], exponent));
}
}
raiser([2, 5, 10], 2);
But I don´t understand what is wrong, because as a result I get only first digit of the array (output – 4). What I´m doing wrong?