Comments in JSX

In JavaScript, you write comments with // or /* */, and in HTML with <!-- -->. Between the tags of JSX, neither works: <!-- is a mistake in the code (Identifier expected.), and // text is ordinary text, which shows on the page.

A comment in JSX is a JavaScript comment in curly braces:

<main>
    {/* The organizers send the lineup on Monday. */}
    <h1>Summer Sounds</h1>
</main>

The braces say "here comes JavaScript", and in them is only a comment, which JavaScript skips. Above return, outside JSX, you write comments as you always have, with //.

Comments are also handy for hiding part of the page for a while, without deleting it: put the elements between {/* and */}, and they're gone from the page until you remove the comment again.

Instructions

Above the list, add a comment for the others who work on the app: Prices are in euros, with VAT. The page doesn't change: comments don't show.

Saturday's tickets are sold out. Hide Saturday's li with a comment, so that it's easy to show it again when more tickets come.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

Back

8/9

Next