2.0 KiB
2.0 KiB
id | title | challengeType | isRequired | videoUrl | localeTitle |
---|---|---|---|---|---|
5a24bbe0dba28a8d3cbd4c5e | Add Comments in JSX | 6 | false | 在JSX中添加注释 |
Description
{/* */}
来包含注释文本。 Instructions
div
元素中的某处添加注释,而不修改现有的h1
或p
元素。 Tests
tests:
- text: 常量<code>JSX</code>应该返回一个<code>div</code>元素。
testString: 'assert(JSX.type === "div", "The constant <code>JSX</code> should return a <code>div</code> element.");'
- text: <code>div</code>应包含一个<code>h1</code>标记作为第一个元素。
testString: 'assert(JSX.props.children[0].type === "h1", "The <code>div</code> should contain an <code>h1</code> tag as the first element.");'
- text: <code>div</code>应该包含一个<code>p</code>标签作为第二个元素。
testString: 'assert(JSX.props.children[1].type === "p", "The <code>div</code> should contain a <code>p</code> tag as the second element.");'
- text: <code>JSX</code>应该包含一条评论。
testString: 'getUserInput => assert(getUserInput("index").includes("/*") && getUserInput("index").includes("*/"), "The <code>JSX</code> should include a comment.");'
Challenge Seed
const JSX = (
<div>
<h1>This is a block of JSX</h1>
<p>Here's a subtitle</p>
</div>
);
After Test
console.info('after the test');
Solution
// solution required