The Right Age چالش 3 از جلسهی 12، متوسط
این بازی برای بچههای ۷ تا ۱۲ سال است. سن را از age بخوان و عددش کن.
- اگر سن بزرگتر از 6 و کوچکتر از 13 بود: لامپ روشن شود و در msg نوشته شود Welcome.
- وگرنه: لامپ خاموش شود و نوشته شود Sorry.
<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
.lamp { font-size: 80px; width: 130px; margin: 12px auto; border-radius: 24px; background: #334155; filter: grayscale(1); opacity: 0.5; }
.lamp.on { background: #fde047; filter: none; opacity: 1; }
</style>
<div id="lamp" class="lamp">💡</div>
<input id="age" placeholder="age">
<button id="go" onclick="press()">Go</button>
<p id="msg"></p>
<script>
let lamp = document.getElementById("lamp");
let line = document.getElementById("msg");
function press() {
}
</script>
راهنما و جواب این چالش · برگشت به درس جلسهی 12: و، یا، نه · چالش بعدی: Alarm
بیشتر بخوان: جاوااسکریپت چیست؟ از دکمهی وب تا Node.js