Labs ICT
Pro Login

Style Guide

Naming Conventions

Use camelCase for variables and functions, PascalCase for classes, and UPPER_SNAKE_CASE for constants.

const MAX_ATTEMPTS = 5;

let userName = "Alice";
function getUserData() { }

class UserProfile { }

const isActive = true;
const totalPrice = 99.99;
Try it Yourself →

Formatting & Indentation

Use 2 spaces for indentation. Keep lines under 80-100 characters. Place opening braces on the same line.

if (condition) {
  doSomething();
} else {
  doOther();
}

const items = ["apple", "banana", "cherry"];

function calculateTotal(items, taxRate) {
  const subtotal = items.reduce((sum, item) => sum + item.price, 0);
  return subtotal * (1 + taxRate);
}
Try it Yourself →

Consistency Practices

Use const by default, let only when reassigning. Use semicolons. Prefer arrow functions for short callbacks.

const multiply = (a, b) => a * b;

const numbers = [1, 2, 3, 4];
const doubled = numbers.map(n => n * 2);

function process(data) {
  const result = [];
  for (const item of data) {
    if (item.isValid) {
      result.push(item);
    }
  }
  return result;
}
Try it Yourself →