Skip to content
beginner

Interface Definition

Define an interface for a User object, inferring each property's type from how the property is used below it.

_________ User {
  id: ______;
  name: ______;
  email: string;
  age___: number;
}

function formatUserId(user: User): string {
  return `#${user.id.toFixed(0).padStart(4, '0')}`;
}

function greetUser(user: User): string {
  return `Hello, ${user.name.toUpperCase()}!`;
}
0/4 filled tab moves · Ctrl+↵ submits · Ctrl+Shift+↵ runsstarter code