- Start - Minimum Requirements - Create /Open /Execute - Installing PromptSync - Finishing the Tutorial - Explanation - Questions
In this repository I will teach you how to make a Js code (JavaScript) where there is a common data input, using the VScode terminal without using a CSS/HTML website. The problem encountered was that in Visual Studio Code it is not possible to receive values from the keyboard for conventional data entry, just like in Python and Java
- 1 You must have installed Node.js for us to use the Library
- 2 Visual Studio Code must be installed together
- 3 In Visual Studio Code, install the extensions: Code Runner, JavaScript (ES6) code snippets
- 1 - Open your computer's Command Prompt
- 2 - Type "node" as shown in the image
- 3 - If the Node version appears, it means everything is ok
To get started, we must create a folder where our JavaScript code will be stored
- 1 - Open your file explorer
- 2 - Create a folder (any name), in this case the name of the folder created was: "PromptSyncGit"
Now open your Visual Studio Code and from there, open the folder you created
- 1 - Go to file
- 2 - Open the folder
- 3 - Select the folder created which was: "PromptSyncGit"
- 4 - Finally, create a JavaScript file, with a name of your choice, example in the image: "App.js"
Before running the application we must add a very important line of code
- 1 - With the source folder open and the JavaScript file created, you will enter the following code
- 2 - Always leaving it on the 1st line of code
const entrada = require('prompt-sync')({sigint: true});
We have reached the icing on the cake, this is where everything changes
- 1 - Initially, look at the folder you created, it will only have the JavaScript file, as in the 1st photo below: App.js
- 2 - In code space, go to terminal
- 3 - New terminal
- 4 - Note: If the terminal does not open in the folder where the code is, you can use the command "cd"+{NameOfDirectory}
- 5 - Now in the terminal type the following command: npm install prompt-sync
After typing the command, you can see that a new folder and files have been added to your project folder, or everything can be contained in just one folder
With everything ready, I created a simple code with data entry and its return
const entrada = require('prompt-sync')({sigint: true});
The input variable can be a name of your choice, but it is what goes into your code when there is data input.
const entradaDados = require('prompt-sync')({sigint: true});
let idade = Number.parseInt(entradaDados("Digite um número: "));
require('prompt-sync')
This is very simple, require is making a request for the data that was downloaded from prompt-sync
({sigint: true});
It tells you whether the data entry condition is true or false, if you go now and change from "true" to "false", the code will not be able to capture whether there was a data entry, or rather, it will deny this entry
In the link below is the video that was used to produce this repository:
https://youtu.be/1TzCYVTC9tc?si=zmhZPPBLgPT5kwXa
If you were unable to do so or have any questions regarding the matter, please contact me using any of the methods below: