Skip to content

Latest commit

 

History

History
230 lines (157 loc) · 6.77 KB

README.en.md

File metadata and controls

230 lines (157 loc) · 6.77 KB

Welcome to my tutorial 😃

Stars Watchers GitHub commit activity (branch) Follows

What will I learn her? 🤷‍♂️

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

Minimum Requirements:

  • 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

  • Node.JS - Visual Studio Code

NodeJS Visual Studio Code

Verify that Node.JS is installed as follows:

  • 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

Create

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"

Open

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"

Execute

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});

Installing PromptSync

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

Finishing the Tutorial

With everything ready, I created a simple code with data entry and its return

  • 1 - In the terminal type "node"+ file name, which would be JavaScript, as follows: "node App.js"

Explanation:

What does this line of code actually mean?

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.

Example:

const entradaDados = require('prompt-sync')({sigint: true});
let idade = Number.parseInt(entradaDados("Digite um número: "));

What does require mean?

require('prompt-sync')

This is very simple, require is making a request for the data that was downloaded from prompt-sync

And sigint: true?

({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

Reference used for the tutorial:

In the link below is the video that was used to produce this repository:

https://youtu.be/1TzCYVTC9tc?si=zmhZPPBLgPT5kwXa

YouTube

Questions:

If you were unable to do so or have any questions regarding the matter, please contact me using any of the methods below:

Thanks for coming here, see you in the next tutorial 😀👍

✮ READ THIS IN OTHERS LANGUAGES:

Português Española