-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.js
44 lines (32 loc) · 921 Bytes
/
hello.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// const mission = "learn";
const mission = process.argv[2];
/*
Process.argv - Array of strings
process.argv[0] - Node path i.e. where the node is installed
process.argv[1] - File path i.e. where the file that is going to execute, in this case, hello.js.
procees.argv[n] - from index 2 onwards, anything that will be passed as argument while running the file
Ex., node hello.js
[
'/usr/local/bin/node',
'/media/sujata/MyVolume/Udemy/ZTM Node/Foundations/hello',
]
Ex., node hello.js playing
[
'/usr/local/bin/node',
'/media/sujata/MyVolume/Udemy/ZTM Node/Foundations/hello',
'playing',
]
Ex., node hello.js playing games
[
'/usr/local/bin/node',
'/media/sujata/MyVolume/Udemy/ZTM Node/Foundations/hello',
'playing',
'games'
]
*/
console.log(process.argv);
if (mission === "learn") {
console.log("Time to write some Node code!");
} else {
console.log(`Is ${mission} really more fun?`);
}