I have a really small knowledge of JS And I was wondering that if someone inputted a number, if they could tell it was prime.
function prime(num) {
for (var i = 2; i < num; i++) {
if (num % i === 0 && i !== num) {
break;
} else {
console.log("true")
}
}
}
My sister gave me this challenge, and I don't know how to do this... Any hints or tips, or a code I could dissect and understand how it works?
Thanks,