جواب «Step 1: The Data» چالش 1 از جلسهی 10
سؤال
قدم اول: دادههای کلاس.
- آرایهای به اسم names با نوع string[] بساز: "Sara"، "Ali"، "Mina" و "Reza".
- آرایهای به اسم marks با نوع number[] بساز: 18، 9، 20 و 13 (به همان ترتیب).
- تعداد دانشآموزها را نشان بده: show("Students", names.length);
برنامه باید Students 4 را بنویسد.
راهنما
const names: string[] = ["Sara", "Ali", "Mina", "Reza"]; و const marks: number[] = [18, 9, 20, 13];
یک جواب درست
<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">
// 1. the names and the marks
const names: string[] = ["Sara", "Ali", "Mina", "Reza"];
const marks: number[] = [18, 9, 20, 13];
show("Students", names.length);
</script>
اول خودت امتحان کن؛ جوابهای دیگر هم قبول است. برگرد و خودت حلش کن