What is the correct syntax I am missing here?

// DO NOT CHANGE THE LINE BELOW.
const n = prompt("Enter a number: ");

let num = getLargestPrimeNumber(n);

function isPrime(num) {
if (num <= 1){
return false
}
else if (num > 1){
for(let i = 2, s = Math.sqrt(num); i <= s; i++)
if(num % i === 0) return false;
return num > 1;
}
}

The syntax is not the issue … and that last return should be outside the loop.
You seem to be missing a getLargestPrimeNumber function in that code.

1 Like