Data Visualization with D3 - Work with Data in D3

Tell us what’s happening:
My code seems to be identical with code from the Hint
yet the output says Your document should have 9

h2

elements. The text in the

h2

elements should say

New Title

. The capitalization and spacing should match exactly.
Your code so far

<body>
  <script>
    const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

    // Add your code below this line

d3.select ("body")
  .selectAll("h2")
  .data("dataset")
  .enter()
  .append("h2")
  .text("New Title")
  
  


    // Add your code above this line
  </script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.21608.199 Safari/537.36 Avast/114.0.21608.199

Challenge: Data Visualization with D3 - Work with Data in D3

Link to the challenge:

Hi there! Welcome to the community.

Looks like you’ve accidentally included quotes around the dataset variable name. Instead of looping through the array, this causes the code to loop through each character in the string which is why you still get 7 elements.

Thanks a lot brother :handshake:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.