There are a few ways for you to run JavaScript on your computer. These are the main two ways.
- Browser (Chrome, Safari, Edge)
- In your Terminal or Command prompt using Node.JS
Running custom JavaScript in your browser
The easiest way to do this that I know of, is you can create a file on your computers desktop. Like this.
Open a text editor, like Notepad, or Visual Studio Code. https://code.visualstudio.com/
Save a file that looks like this.
<html>
<head></head>
<body>
<p>Your own webpage, with a JavaScript popup!</p>
</body>
<script>
window.alert('Hello World");
</script>
</html>
You can make this file using a text editor to make a .html file.
This one is example.html
Running JavaScript from the command line
You can achieve this with node.js. You’ll need to download and install it from here.
The LTS means long term support, and is a great version to start out with.
Once you have it installed, create a file, and open up a terminal to run it.
If you’re using visual studio code, you can do that here. It looks like this.