DevPath · Learn to code ESPTEN

Practical projects

How to approach a project

From exercises to projects

A project integrates many concepts at once. The key is not knowing more syntax, but breaking down the problem into manageable parts.

A 4-step method

  1. Understand the problem: what comes in, what goes out, what edge cases are there?
  2. Split into functions: each function solves a small, testable part.
  3. Implement the minimum: get the simple case working before the complex ones.
  4. Test and refactor: add tests and clean up the code.

Example: form validator

Instead of one giant function, separate responsibilities:

function isValidEmail(email) {
  return /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email);
}
function hasMinLength(text, min) {
  return text.length >= min;
}
function validateForm(data) {
  const errors = [];
  if (!isValidEmail(data.email)) errors.push("Invalid email");
  if (!hasMinLength(data.password, 8)) errors.push("Password too short");
  return { valid: errors.length === 0, errors };
}

Each piece is simple, easy to test and reusable. That is how you build maintainable software.

Examples

Compose small functions

const isPositive = (n) => n > 0;
const isInteger = (n) => Number.isInteger(n);
function validateQuantity(n) {
  return isPositive(n) && isInteger(n);
}
console.log(validateQuantity(5));
console.log(validateQuantity(-2));
console.log(validateQuantity(3.5));
Put this into practice

DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.

Start free in the app →
Process data with map, filter and reduce →