Could you help me with this code

I am not able to understand this code it says The code editor has a JSX element similar to what you created in the last challenge. Add a comment somewhere within the provided div element, without modifying the existing h1 or p elements. so I tried to do the same thing but it’s still wrong

  This is my code

const JSX = (
<div>
  {/*<h1>This is a block of JSX</h1>*/}
  <p>Here's a subtitle</p>
</div>
);

Challenge: Add Comments in JSX

Link to the challenge:

But that comments out the h1 element, which is supposed to be left intact.

it fine I got the code I found out that it should be like this:

const JSX = (
 <div>
 {/* Web */}
<h1>This is a block of JSX</h1>
<p>Here's a subtitle</p>
</div>
);

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Thank you for the solution will really in future

Like you can observe, JSX has its own syntax(well, taken from HTML and slightly changed to be fit to place within JS), but it doesnt have its own tags to insert comments, but rather a smart work around. The curly braces are actually used to insert JS within JSX(odd right, as JSX is found within JS…). When we have {/* ... */}, we actually enclose space to write JS code within the JSX and we simply use JS comments /* ... */. This is, at least for me, easier way to learn and understand and subsequently, use comments in JSX. You will see later in the challenges, how you will use other JS code, beside comments, which you will put within { ... }, whenever you want to place it inside JSX.

oh now I get it I should add the {/* ... */} now I get it thank you so much I don’t know how I can thank you more but thanks for the hint

to be clear, the three dots between {/* and */} are only a placeholder, where you can write your comment ^^

1 Like

it’s okay I got it it really payed of the price