Index Power

Index Power

You are given an array with positive integers (number) and an integer (number) N. You should find the N-th power of the element in the array with the index N. If N is outside of the array, then return -1. Don't forget that the first element has the index 0.

Let's look at a few examples:
- array = [1, 2, 3, 4] and N = 2, then the result is 32 == 9;
- array = [1, 2, 3] and N = 3, but N is outside of the array, so the result is -1.

example

Input: Two arguments.An array of integers (number) and an integer (number).

Output: The result as an integer (number).

Examples:

assert.strictEqual(indexPower([1, 2, 3, 4], 2), 9);
assert.strictEqual(indexPower([1, 3, 10,...
You should be an authorized user in order to see the full description and start solving this mission.
19