Fundamentals2 / 5
Up next

Functions and arrows

// an explicit return type documents the contract
function add(a: number, b: number): number {
  return a + b;
}

// an arrow function with an inferred return type
const square = (n: number): number => n * n;

console.log(add(2, 3), square(4));
What you're solving

typed parameters, return types, and arrow functions