Can someone explain this javascript code I took from MDM web docs?

I understand everything about this code (or at least I thought I did) except the fact that it includes the number “2” in the new filtered array. I know the code is supposed to return all prime numbers but if (num % i == 0) { return false }, shouldn’t that make it so that it skips the number “2”?

const array = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];

function isPrime(num) {
  for (let i = 2; num > i; i++) {
    if (num % i == 0) {
      return false;
    }
  }
  return num > 1;
}

console.log(array.filter(isPrime)); // [2, 3, 5, 7, 11, 13]

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

Answer

In the for loop, the variable i starts from 2, and the condition checks whether num > i, therefore the for loop never executes if num equals 2.

However, 2 is included in the final result because of the final statement return num > 1 (since 2 is greater than 1).