First CLI App using Node JS for Beginner’s

Prerequisite:
- https://repl.it
- Create an account in repl.it
Step-1:
- Create new repl
- Inside it, Choose JS or NodeJS to create a javascript repl.

Step-2:
Installing package for use code written by others via this system.
1)readlineSync
NPM, or Node Package Manager, helps us utilize 3rd party packages.
The readline module provides an interface for reading data from a Readable stream one line at a time. It can be accessed using:
Simple Case:
var readlineSync = require('readline-sync');var userName = readlineSync.question('May I have your name? ');console.log('Hi ' + userName + '!');
These packages will help us solve many problems by taking input from the user.
2)chalk:
The chalk library offers powerful and simple methods to enforce ANSI colors and styles to our terminal output.
//index.jsconst chalk = require('chalk');
console.log(chalk.red("Lost in cosmos!"));

Step-3:
Using “Array” to Store Multiply value at a time.
An array is a special variable, An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Syntax:
var fruits = new Array( “delhi” ,“kashmir” ,“maharashtra” );

Step-4) Using Functions,Condition,for loop.
Function:
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().
Syntax:
function functionName(parameterOne, parameterTwo) {
// processing
return outputValue;
}
Condition:
Conditional statements are used to perform different actions based on different conditions.
- Use “if” to specify a block of code to be executed, if a specified condition is true
- Use “else” to specify a block of code to be executed, if the same condition is false
- Use “else if” to specify a new condition to test, if the first condition is false
- Use a “switch” to specify many alternative blocks of code to be executed
for loop:
Loops are handy, if you want to run the same code over and over again, each time with a different value.
Syntax:
for (statement 1; statement 2; statement 3) {
// code block to be executed
}
Console.log():
The console.log() is a function in JS that is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.

Step-5) Combine All the steps to create a CLI App.

Output:
