incrementing?
let prime_num = (num)=>{
if (typeof num === "number"){
if (num<2){
return false;
}
for(var i=2; i<num; i++){
if(num%i === 0){
return false;
}
else{
return true
}
}
}
else{
return "input must be a number..."
}
}
console.log(prime_num(3))
Because you use an if and else statement in the loop.
Heh, nice interview question
Обсуждают сегодня