What could be the reason for this code not printing anything to the console? Here is a breakdown of the issue:
Create a JavaScript function that takes an array with an integer N and checks if the given N is a prime number (meaning it is only divisible by itself and 1 without any remainder).
var n = ['2'];
function isPrime(n) {
if (n < 2) {
return false;
}
var isPrime = true;
for(var i = 2; i < Math.sqrt(n); i += 1) {
if (n % i === 0) {
isPrime = false;
}
}
return isPrime;
}
return isPrime(n);