Work with Data in D3: Help

Tell us what’s happening:
The consol is telling me that my document should have 9 h2 elements even though there are 9 h2 elements with New Titles.
And there is another error “Cannot read property ‘length’ of null”.
Please explain what is going on here if you understand.

Your code so far

<body>
  <script>
    const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];
  
    d3
    .select("body")
    .selectAll("h2")
    .data(dataset)
    .enter()
    .append("li")
    .text("New Title");
    
  </script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:

Just noticed that I missed the semicolon, but still getting those error :grin:

Sometimes, if I get an error I try the code on Firefox and the code will pass. I just did the same and now getting another error instead of the second one: $(…).text(…).match(…) is null.

Why did you append <li>s to all of the <h2>s you selected? :face_with_raised_eyebrow:

1 Like

Thanks so much :clap: :clap: :raised_hands:

1 Like