Master AI & Build your First Coding Portfolio with SkillReactor | Sign Up Now

Lesson 2 - Basic JavaScript Syntax


Comments are short notes, describing the purpose of a specific code block. JavaScript ignores comments when running your code.

Using comments is one of the essential best practices that increases code understandability and is helpful when working as a team.

In JavaScript, you have two types of comments available:

  1. Single-line comments: This type of comment allows you to provide single-line notes in your code. For example:
// Initializing variable
let x = 10;
console.log("Value of x:", x);
  1. Multi-line comments: If you need to include large notes in your code such as describing a function, use multi-line comments. This is helpful when describing a function.

For example:

Function to add two numbers
Return value: integer
function addNum(a, b) {
  return a + b;
console.log("Result:", addNum(10, 10));

See how we used the multi-line comment in the code above. Don't get scared about the function, we'll discuss it later in this course.