Skip to content
beginner

Type Annotations

Add type annotations to function parameters, and infer each return type from what the function actually computes.

function calculateArea(width________, height: number): number {
  return width * height;
}

function isSquare(width: number, height: number): _______ {
  return width === height;
}

function describeShape(width: number, height: number): ______ {
  return isSquare(width, height) ? 'square' : `${width}x${height} rectangle`;
}
0/3 filled tab moves · Ctrl+↵ submits · Ctrl+Shift+↵ runsstarter code