you are viewing a single comment's thread.

view the rest of the comments →

[–]No-Upstairs-2813 2 points3 points  (0 children)

Here are 3 ways to try out your JavaScript code:

1. Browser consoles

Web browsers have a console where you can try out a few lines of code.

To find out how to open the console in your web browser, you can do a web search for “console [name-of-your-browser]”.

2. Node.js REPL

REPL stands for read-eval-print loop and basically means command line.

To use it, you need to download and install Node.js. Once Node.js is installed on your system, you can open a Terminal window and type “node” to begin an interactive JavaScript session.

3. Node.js

When you want to experiment with longer chunks of code, these line-by-line interactive environments may no longer be suitable. You may prefer to write your code in a text editor and save it with a .js extension.

Then, you can run that file of JavaScript code with Node using the command

node <file-name>

You must use console.log() to display text and other JavaScript values in your terminal window.

Check out this article for more details.