JavaScript for Absolute Beginners 1

In this tutorial, we’re going to write a JavaScript program to swap two numbers. In this JavaScript series, I assume you have no programming experience. Throughout the series, you’ll learn how to build an actual website from scratch.



Other tutorials of this series.

Notes for this tutorial:

There are many programming languages

  • JavaScript
  • Python
  • Java
  • C++
  • C#
  • etc.

You can use JavaScript to develop

  • frontend
  • backend
  • mobile apps
  • desktop apps
  • etc.

Task for this tutorial: Write a JavaScript program to

  1. Store two numbers into memory
  2. Swap the two numbers
  3. Print the two numbers onto the screen

Install the following

  • Node.js: JavaScript runtime environment. For running JS program
  • Visual Studio Code: IDE or integrated development environment

Declaring variable

Declaring variable
1
let num1 = 123;

Print things to screen

Print things to screen
1
console.log("something to print");

String concatenation

String concatenation
1
let str3 = str1 + str2;

Formatted string

Formatted string
1
let str = `The number is ${someNumVariable}`;

Run JS program

Run JS program
1
$node your-program.js

The source code of the program in this tutorial on GitHub.