Implement integer exponentiation faster than repeated multiplication
The solution 1 is still a repeated multiplication. The only difference is that the multiplication is implemented as a repeated addition:

    for (let j = 1; j &lt; x; j++) {
        tmp += res;
    }


is a very long way to say

    tmp = res * x;


and obviously it doesn't make the code any faster.



The second solution is almost correct. It fails for negative y (negative is still integer!), and the handling of pow2(0, 0) is questionable.

Besides that, try to avoid the recursion; recursive calls are expensive, and the goal of the exercise is to achieve the maximal speed. There does exist a true honest-to-goodness iterative algorithm.