--- id: 5a24bbe0dba28a8d3cbd4c5e title: Add Comments in JSX challengeType: 6 forumTopicId: 301376 dashedName: add-comments-in-jsx --- # --description-- JSX is a syntax that gets compiled into valid JavaScript. Sometimes, for readability, you might need to add comments to your code. Like most programming languages, JSX has its own way to do this. To put comments inside JSX, you use the syntax `{/* */}` to wrap around the comment text. # --instructions-- 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. # --hints-- The constant `JSX` should return a `div` element. ```js assert(JSX.type === 'div'); ``` The `div` should contain an `h1` tag as the first element. ```js assert(JSX.props.children[0].type === 'h1'); ``` The `div` should contain a `p` tag as the second element. ```js assert(JSX.props.children[1].type === 'p'); ``` The existing `h1` and `p` elements should not be modified. ```js assert( JSX.props.children[0].props.children === 'This is a block of JSX' && JSX.props.children[1].props.children === "Here's a subtitle" ); ``` The `JSX` should use valid comment syntax. ```js assert(/
[\s\S]*{\s*\/\*[\s\S]*\*\/\s*}[\s\S]*<\/div>/.test(code)); ``` # --seed-- ## --after-user-code-- ```jsx ReactDOM.render(JSX, document.getElementById('root')) ``` ## --seed-contents-- ```jsx const JSX = (

This is a block of JSX

Here's a subtitle

); ``` # --solutions-- ```jsx const JSX = (

This is a block of JSX

{ /* this is a JSX comment */ }

Here's a subtitle

); ```