Create a folder called
learnjs and inside it, a file called
tutorial.js and enter the following text inside:
That’s all. One-liner.
If the code doesn’t work, you’ll get some errors that say what’s wrong.
In the same
learnjs folder, create an
index.html file with the following content:
The most relevant line for us is
<script src="tutorial.js"></script> which loads
index.html with a browser. You’ll see an empty page, that is fine.
Safari (First You Need toEnable “Develop” Menu)
First, you need to install Node.js from https://nodejs.org/en/ Once you did that, verify that all is OK by checking the node.js version. In a terminal/cmd run the following:
If that works go to the
learnjs folder and, again using the terminal, type:
You should see “Hello, World!” displayed.
Visual Studio Code
Most programmers use some sort of IDE to help them code faster and with fewer mistakes. Not to mention project structure and settings.
- Use an IDE like Visual Studio Code to be more productive