How to add two numbers in console using Node.js ?
In this article, we will see how to add two numbers in the console using NodeJS. For this purpose, we need to know about a node package called prompt. It helps to take user input from the console. We would use its method prompt.get() to take user input.
Create NodeJS Application: Initialize the NodeJS application using the following command:
Module Installation: Install the prompt module using the following command.
npm install prompt
Implementation: Create an app.js file and write down the following code in it.
Step to run the application: Run the app.js file using the following command.
Output: Now enter the user input and view output in the console.
So this is how you can add two numbers in the console using nodeJs. Prompts help us to take input from users. It also supports validation and defaults over the input.