* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.5 KiB
1.5 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7fa6367417b2b2512bc3 | Select a Group of Elements with D3 | 6 | 301490 | select-a-group-of-elements-with-d3 |
--description--
D3 also has the selectAll()
method to select a group of elements. It returns an array of HTML nodes for all the items in the document that match the input string. Here's an example to select all the anchor tags in a document:
const anchors = d3.selectAll("a");
Like the select()
method, selectAll()
supports method chaining, and you can use it with other methods.
--instructions--
Select all of the li
tags in the document, and change their text to "list item" by chaining the .text()
method.
--hints--
There should be 3 li
elements on the page, and the text in each one should say "list item". Capitalization and spacing should match exactly.
assert(
$('li')
.text()
.match(/list item/g).length == 3
);
Your code should access the d3
object.
assert(code.match(/d3/g));
Your code should use the selectAll
method.
assert(code.match(/\.selectAll/g));
--seed--
--seed-contents--
<body>
<ul>
<li>Example</li>
<li>Example</li>
<li>Example</li>
</ul>
<script>
// Add your code below this line
// Add your code above this line
</script>
</body>
--solutions--
<body>
<ul>
<li>Example</li>
<li>Example</li>
<li>Example</li>
</ul>
<script>
d3.selectAll("li")
.text("list item")
</script>
</body>