I wrote another answer. But I don't understand this.
although, i run chrome debugger but.. i cant understand well..
result = true
// is passed
i don't understand well.. i submit another answer but i want to know why is it just pass.. i need explain more. and I would like to fix from this code. thank you.
function isPrime(num) {
let result;
for(let i = 1 ; i <= num ; i++) {
if(num[i] / num[i] === 1 && num[i] / num[i] === num[i]){
result = true
} else {
result = false
}
}
return result
}
debugger;
let output = isPrime(2);
console.log(output); // --> true
output = isPrime(6);
console.log(output); // --> false
output = isPrime(17);
console.log(output); // --> true

Aucun commentaire:
Enregistrer un commentaire