// NodeJS: It is a JavaScript Runtime Environment
// =======
//
// After NodeJS installation, in terminal, write: node
// Output:
// ========
// Welcome to Node.js v14.16.0.
// Type ".help" for more information.
// > .help
// .break Sometimes you get stuck, this gets you out
// .clear Alias for .break
// .editor Enter editor mode
// .exit Exit the REPL
// .help Print this help message
// .load Load JS from a file into the REPL session
// .save Save all evaluated commands in this REPL session to a file
//
// Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL
//
//---------------------------------------------------------------------------
// Write any REPL expression:
// ===========================
// > 1+2+3*2+6/2+7%4 === 15
// OUTPUT:
// =======
// true
//
// Exit the REPL mode with command: .exit
//
//------------------------------------------------------------------------------
// More Notes:
// ===========
// 1> For NodeJS, Global object is "global", just like "window" was for Browser
// 2> create a dir with: mkdir
// 3> list out the files in the dir with: ls
// 4> cd to change the dir: cd
// 5> to move out of the current dir to its parent dir: cd ..
// 6> to remove/delete an empty dir: rm -r
// 7> to remove/delete non-empty dir(forcefully): rm -rf
// 8> to run a js file, go to the dir where the js file is present and write:
// > node
//
//----------------------------------------------------------------------------------
// Process:
// =========
// It is an object inside NodeJS that contains info about
// all the process currently running and
// it is also used to get the inputs from the command line.
//
// Go to REPL mode by typing: node
// then, write: process
// then, write: process.cwd();
// this will give you the current working directory,
// that is the file being run with its path.
//
// Now, check below code from Index.js file below:
console.log(process.argv);
const arr = process.argv.slice(2);
//in above code,
//process.argv returns an array whose elements,
//excluding the first two elements, represents the
//input values passed as command line arguments.
//we use slice(2) to exclude the first two elements
//which we don't need.
for(let user of arr){
console.log(`Hello from ${user}`);
}
// Now in terminal, exit the REPL mode( by typing, .exit),
// and run: node index.js Sam Ram Rahim
// OUTPUT:
// =======
// [
// 'C:\\Program Files\\nodejs\\node.exe',
// 'E:\\Newfolder\\CSE\\Docs\\CSE\\Miscellaneous\\Study\\Web Dev\\Nagarro Bootcamp\\Web Development\\Lecture_10\\01-NodeJS_Intro\\index.js',
// 'Sam',
// 'Ram',
// 'Rahim'
// ]
// Hello from Sam
// Hello from Ram
// Hello from Rahim
//
//--------------------------------------------------------------------------------
//
// Almost unrelated but, a programming problem - FizzBuzz:
// 1- FizzBuzz.js Click here
// 2- OptimisedFizzBuzz.js Click here