Find the Red Lines چالش 5 از جلسهی 12، سخت
این برنامه دو گوشی را ثبت میکند و باید 1001 Reza و BLUE را نشان بدهد.
سه خط قرمز دارد. Phone درست است و نباید عوض شود.
- شمارهی سریال فقطخواندنی است: خطی که آن را عوض میکند پاک کن.
- اسم یکی از فیلدهای other غلط نوشته شده.
- رنگ اختیاری است: قبل از toUpperCase با if بپرس که هست یا نه.
<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
#out { direction: ltr; text-align: left; font: 16px monospace; margin: 12px 0; padding: 12px; min-height: 28px; border-radius: 12px; background: #0f172a; color: #e2e8f0; white-space: pre-wrap; overflow-wrap: anywhere; }
#out .line { min-height: 22px; }
</style>
<pre id="out"></pre>
<script type="text/typescript">
interface Phone {
readonly serial: number;
owner: string;
color?: string;
}
const phone: Phone = { serial: 1001, owner: "Mina" };
phone.serial = 2002;
phone.owner = "Reza";
show(phone.serial, phone.owner);
const other: Phone = { serial: 1002, owner: "Ali", colour: "blue" };
show(other.color.toUpperCase());
</script>
راهنما و جواب این چالش · برگشت به درس جلسهی 12: اینترفیس · چالش بعدی: The Club Card
بیشتر بخوان: جاوااسکریپت چیست؟ از دکمهی وب تا Node.js