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

جواب «Big Letters» چالش 5 از جلسه‌ی 2

سؤال

کلمه در متغیر word است. دو چیز نشان بده:
- یک h1 با id برابر word که کلمه را با حروف بزرگ بنویسد: REACT
- یک p با id برابر len که بنویسد 5 letters

از toUpperCase() و length استفاده کن؛ عدد و کلمه را دستی ننویس.

راهنما

<h1 id="word">{word.toUpperCase()}</h1> و <p id="len">{word.length} letters</p>

یک جواب درست

<style>
body { font-family: sans-serif; text-align: center; padding: 16px; }
button, input, select { font-size: 16px; min-height: 40px; margin: 4px; }
</style>

<div id="root" dir="ltr"></div>

<script type="text/jsx">
import { createRoot } from "react-dom/client";

function App() {
  const word = "react";
  return (
    <div>
      <h1 id="word">{word.toUpperCase()}</h1>
      <p id="len">{word.length} letters</p>
    </div>
  );
}

createRoot(document.getElementById("root")).render(<App />);
</script>

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