Colour from a Variable چالش 5 از جلسهی 4، سخت
رنگ تیم در متغیر color است. به div سه چیز بده:
- کلاس card
- رنگ زمینه (backgroundColor) از متغیر color
- رنگ متن white
اسم رنگ زمینه را دستی ننویس؛ از متغیر استفاده کن.
<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
.card { max-width: 260px; margin: 12px auto; padding: 16px; border: 2px solid #334155; border-radius: 16px; background: #f8fafc; }
</style>
<div id="root" dir="ltr"></div>
<script type="text/jsx">
import { createRoot } from "react-dom/client";
function App() {
const color = "teal";
return (
<div id="box">
<h2>Team {color}</h2>
</div>
);
}
createRoot(document.getElementById("root")).render(<App />);
</script>
راهنما و جواب این چالش · برگشت به درس جلسهی 4: ظاهر قطعهها · چالش بعدی: Find the Bugs
بیشتر بخوان: جاوااسکریپت چیست؟ از دکمهی وب تا Node.js