num > 1 returns a Boolean value depending on value for num.
true if num is greater than 1
false if num is less or equal to 1
let num = 5;
console.log(num > 1); // Logs true
num = 0;
console.log(num > 1); // Logs false
num = 1;
console.log(num > 1); // Logs false
As per the function definition the function is checking the input number is prime or not.
What is a prime number?
A prime number is a number which is divisible only with 1 and that number.
So here in the function the number is consecutively divided by numbers from 2 to that number - 1. If any of the modulus operations return zero, that number is not prime and it returns false.
If nothing return false, then the number should be greater than 1
Please note 1 is not a prime number.
That is why the last comparison is done. To check whether the number is greater than 1. If the number is greater than 1, the number will be prime.
Because if the number is not divisible by any number from 2 to number - 1, that number should be greater than 1 to be prime number.
numis greater than 1.numand1-trueif the number is greater than1,falseotherwise. I’d recommend brushing up on your fundamentals1a prime number? Is zero a prime number? math.stackexchange.com/questions/120/…i < num, what don't you understand aboutnum > 1?