Skip to main content
X

Explore your training options in 10 minutes

JavaScript Tutorials

JavaScript – Hello World

Christina Kopecky - September 11, 2020


One of the very first programs you can write to make sure your Node version works is the “Hello World” program. There are two ways to create the program:  in the terminal or in your code editor of choice (i.e. Visual Studio Code, Vim, etc.). Make sure you have Node installed on your machine to get started.

Terminal

1.In your terminal, type node to start Node.

How the terminal should look after starting Python 3
How the terminal should look after starting Node.

2.Input console.log(“Hello World”) into the Interpreter and hit enter.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses










By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

3.Hello World will show up on the next line! Don’t worry if it says “undefined” in the following line. That just means we haven’t returned anything from a function.

4.If you would like to create a function to test, you can do that too! Here’s how to do that in the terminal:

Node will store the function in memory. If you want to run it, just type helloWorld() in the terminal and hit enter. It’ll return Hello World! in the console.

Code Editor (i.e. Visual Studio Code)

  1. Open up your editor of choice and create a new file and save it as  hello.js.
  2. In your file, input console.log(“Hello World”) into the file and save it.
  3. In your terminal, navigate to the directory/folder you saved your file. Use cd and ls to navigate from directory to directory.
  4. Use node hello.js to run the file. Hello World should show up on the next line.
  5. If you are using VS Code, the “play” button in the upper right hand corner will also run the current file and show the output on the lower half of the screen.

That’s it! You have successfully created a simple program in JavaScript that shows that your Node environment works.

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

Christina Kopecky

About the author: Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.

Skip to main content