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

جواب «One Bar» چالش 1 از جلسه‌ی 12

سؤال

در تابع show() قدِ میله‌ی #bar را n پیکسل کن (با style.height و "px"). اول n برابر 120 است و دکمه‌ی #grow آن را ۳۰ تا بیشتر می‌کند.

راهنما

document.getElementById("bar").style.height = n + "px";

یک جواب درست

<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: Tahoma, sans-serif; margin: 0; background: #f4f6fb; color: #222; }
.screen { max-width: 420px; margin: 0 auto; padding: 16px; }
input, select { font-size: 16px; min-height: 44px; box-sizing: border-box; }
button { font-size: 16px; min-height: 44px; padding: 0 16px; }
</style>
<style>
#bar { width: 60px; background: #4a90e2; border-radius: 6px 6px 0 0; }
</style>
<div class="screen" dir="rtl">
  <h1>یک میله</h1>
  <div id="bar"></div>
  <button id="grow" onclick="n = n + 30; show()">بلندتر</button>
</div>

<script>
let n = 120;

function show() {
  document.getElementById("bar").style.height = n + "px";
}

show();
</script>

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن