AzLearn

تمرين إعادة البناء

Hello World with Types

أعد كتابة سكربت TypeScript يطبع معلومات بسيطة بأنواع واضحة.

typescript ~8 دقيقة مبتدئ
أعد بناء الكود Rebuild

هذا هو الكود. اكتبه بنفسك.

الكود المرجعي
type SystemInfo = {
  appName: string;
  version: string;
  runtime: string;
};

function buildGreeting(name: string, info: SystemInfo): string[] {
  return [
    `Hello, ${name}!`,
    `Welcome to ${info.appName} ${info.version}.`,
    `Runtime: ${info.runtime}`,
  ];
}

const info: SystemInfo = {
  appName: "TypeScript Rebuild",
  version: "1.0.0",
  runtime: "Node.js",
};

for (const line of buildGreeting("friend", info)) {
  console.log(line);
}
اكتب هنا