Software Development

How to Write JavaScript Articles on GeeksforGeeks ?

GeeksforGeeks allows coding lovers to display their programming skills by writing Javascript-based articles. However, a lot of individuals (especially college students or beginners) find it challenging to describe their learnings and talents and contribute to GeeksforGeeks. But now the problem has been solved. This article will guide you through the entire process and guidelines for writing articles at GeeksforGeeks.


Let’s get Started

First and foremost, you need to know how to get started with article writing at GFG along with various other fundamental aspects like why should you contribute, where to write, etc. You can check out this link to know all these details in a comprehensive manner.

How to verify if we can write an article?

Now, you need to check whether you can write an article on a particular topic/problem or not. You can do the same by following the below-mentioned steps:

  • Search the title and problem statement in the Custom Search on GeeksforGeeks. If existing, choose another topic to write.
  • Then search the title, problem statement, and examples (together and/or individually) on Google to find related existing links from other websites. If the same content is available on other websites then it will lead to plagiarism and hence cannot be accepted.

If the article passes the above points, the article can be written.

JavaScript Articles Format and Guidelines

Moving further, let’s check out the format and guidelines that you need to follow while writing JavaScript articles at GeeksforGeeks. The articles should contain the following points:

  1. Problem Statement
  2. Description
  3. Links of prerequisites for the approach if there are any.
  4. List of all possible approaches
  5. Explain each approach one by one with an example
    • Approach name in <h2> tag.
    • Description and step-by-step points regarding how this approach will work.
    • Syntax (add the syntax in <pre> tag)
    • Example
    • Output

Note: In the JavaScript article, it is required to add only JavaScript code (instead of using HTML code as well), and select IDE language to JavaScript. In some cases, if the use of HTML code is mandatory, then write the complete HTML code with JavaScript and select IDE language to HTML.

JavaScript Coding Standard Guidelines

Let’s check out the format and guidelines that you need to follow while writing a coding article at GeeksforGeeks. The programming articles should contain the following points:

Variable Declaration with const and let

For ES2015 or newer versions, let and const should be used in place of var. A declaration always uses const if its value is not changed, otherwise, use let.

// Value can be changed
let myVar="GeeksforGeeks";

// Value cannot be changed
const myVar2 = 'GfG';

Naming Conventions

Use the full words for Variable and function names, and use camel case with a lowercase first letter. Names should be descriptive, but not excessive. 

let myGeek;
const myGeek;

Note: Exceptions are allowed for iterators, such as the use of i to represent the index in a loop.

Code width

Fix the character limit per line (Max 60 Characters including space).


Always use semicolons at the end of statements.

let myGeek = 'GeeksforGeeks';


  • Indentation with Tabs.
  • No whitespace at the end of the line or on blank lines.
  • Unary special-character operators (e.g., ++, –) must not have space next to their operand.
  • Any , and ; must not have preceding space.
  • Any ; used as a statement terminator must be at the end of the line.
  • Any : after a property name in an object definition must not have a preceding space.
  • The ? and : in a ternary conditional must have space on both sides.
  • No filler spaces in empty constructs (e.g., {}, [], fn()).
  • All function bodies are indented by one tab, even if the entire file is wrapped in a closure.


Always put the comments before the code to which they refer, and always use preceded blank lines. Always use a single space between comments and tokens (//) and use the first capital letter.

// Declaring a variable with a string value
let myGeek = 'GeeksforGeeks'

Blocks and Curly Braces

For if/else/for/while/try blocks, always use braces and go to the next line.

If ( x === 4 ) {
} else {

Multi-line Statements

If the given statements are very long, then use a line break after an operator.

let expr = ‘<p>Sum of two numbers ’ + x + ‘ and ‘ + y + 
                ‘ is ‘ + x + y + ‘</p>’;

Line break for Conditional & Logical Operators

If conditional statements are too long, then we can break the statements after operators into multiple lines.

let num1 = 10;
let num2 = 20;
let num3 = 30;
if (
var1 == var2 &&
var2 == var3 &&
var3 == 50
) {

Chained Method Calls

If long-chained methods are used, then use one method call per line.


const object = [

    { name: "Baleno", type: "car" },

    { name: "Apple", type: "fruit" },

    { name: "Chocolate", type: "sweet" },

    { name: "onion", type: "vegetable" }




    .map(item => item.type)

    .reduce((result, fruit) => {


        return [ Set(result)];

    }, []);

Strings Declaration

Use single quotes to define string literals.

const str = ‘GeeksforGeeks’

Use the escape character with a backslash to add single quotes in the string.

let str = ‘Welcome to \’GeeksforGeeks\’’

Array Declaration

For array declaration, please prefer to use [] constructor to create an array rather than Array() constructor.

const arr = [];

// Initializing the array like that:
const arr = [ 1, 2, 3, 5 ];

Last Updated :
07 Aug, 2023

Like Article

Save Article