بتل کد Battle Codeدارد باز می‌شود…

Step 1: A Type on Every Box چالش 1 از جلسه‌ی 5، آسان

قدم اول: به سه جعبه‌ی بالای برنامه نوع بده.
- player متن است: string.
- score و bonus عدد هستند: number.

بعد دو خط قرمز پیدا می‌شود. بخوانشان و مقدارها را درست کن.
حالا کلیک اول باید Sara 5 و کلیک دوم Sara 10 را بنویسد.

<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>

<button id="go" onclick="press()">Add points</button>
<pre id="out"></pre>

<script type="text/typescript">
let player = "Sara";
let score = "0";
let bonus = "5";

function press(): void {
  score = score + bonus;
  show(player, score);
}
</script>

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 5: پروژه: امتیازشماری که غلط جمع می‌زند · چالش بعدی: Step 2: Lock It and Say It

بیشتر بخوان: جاوااسکریپت چیست؟ از دکمه‌ی وب تا Node.js