Technically, it's recursion - because the function does call itself.
But ... it's a poor example in both cases.
The first example runs off the end of the array:
for (let i = 0; i < array.length; i++) {
if (array[i] + array[i+1] === 12) {
If you have three elements, teh valid indices are 0, 1, and 2 - but your loop would add:
array[0] + array[1]
array[1] + array[2]
array[2] + array[3]
If it ever got to a second iteration. Which it won't because there is a return on both sides of the
if
.
So the loop is redundant: it does nothing.
The second version is technically recursion, but in practice it's just a loop that wastes stack space and which will crash with big arrays as a result!
Why would you want to make this a recursive function? It's not a recursive problem, it's iterative!