Home > front end >  Write a function that users determine whether as a prime number, and the pop-up return value (also c
Write a function that users determine whether as a prime number, and the pop-up return value (also c

Time:09-26



<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
<meta HTTP - equiv="X - UA - Compatible" content="ie=edge" & gt;
Document
<script>
The function getDate (num1) {
Var cuont=0;
For (var I=1; i <=num1; I++) {
If (num1 % I==0) {
count++;
}
}
If (count==2) {
Return num1.
} else {
The console. The log (' is not a prime number);

}
}
The console. The log (getDate (2));
</script>

<body>


CodePudding user response:

I am a little white, you don't understand the logic of, but I use a test browser, see the console error variable is undefined, find your variable word write wrong

According to the modified variable operation, still didn't understand operation, I also want to continue to learn

CodePudding user response:

See the word was wrong had changed

CodePudding user response:

Var cuont=0; Then behind you been playing the count, not a thing,
  • Related