Ad
  • Default User Avatar

    The modulo operator (%) returns the remainder after dividing two numbers. If a number is divisible by another, the remainder will be 0, ergo the modulo operation will return 0. In this case, we are checking if a number is an integer. Math.sqrt(n) % 1 will only return a value other than 0 if the return value of Math.sqrt(n) is a decimal, since every integer is divisible by 1. Hope that helps. :)