You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lesson_04/dasiaenglish/lesson_04.md
+7-13Lines changed: 7 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,6 @@
1
1
```Javascript
2
2
#Javascript
3
3
4
-
constreadline=require(`readline`);
5
-
6
-
constrl=readline.createInterface({
7
-
input:process.stdin,
8
-
output:process.stdout
9
-
});
10
-
11
4
functionfindPrimes(numberToCheck) { // A machine that helps find prime numbers
12
5
13
6
if (numberToCheck <=1){
@@ -30,15 +23,16 @@ function findPrimes(numberToCheck) { // A machine that helps find prime numbers
30
23
}
31
24
} //closing the loop of if it is a prime number or not
32
25
33
-
rl.question(`Enter a number to check if it\'s prime:`, (input)=>{
34
-
let number =parseInt(input);
26
+
constinput=process.argv[2]; // telling the computer to save the 3rd thing you type
35
27
36
-
if (isNaN(number)) {
37
-
console.log("Please enter a valid number.");
28
+
let number =parseInt(input); // if it types a word the computer does the math and makes it a number
29
+
30
+
if (isNaN(number)) { // make sure you type a number
31
+
console.log("Please enter a valid number."); // letting the user know you have to type a number
38
32
} else {
39
-
console.log(findPrimes(number));
33
+
console.log(findPrimes(number));//now the computer can check if it is prime or not
40
34
}
41
-
});
35
+
42
36
// credit from Coding with John youtube video https://www.youtube.com/watch?v=I9-3drnfyp0 and Chatgpt for a explanation of things I still might have been confused about
0 commit comments