Having problem Working with Dynamic Data in D3

What is wrong with my code? I think its producing the desired output. Also I’m not getting how the “selection.text” to be used?

Your code so far

    const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];
      // Add your code below this line
        for (var d=0;d<dataset.length;d++){
          .text(dataset[d]+" USD").enter();
      // Add your code above this line

Your browser information:

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

Link to the challenge:

You won’t need the for loop. The code will iterate for each item in the dataset.

Hello Vinay,

If you check the challenge code, it seems it adds empty H2 tags with following code

Then you add another set of H2 tags. The issue comes here when test expected the first H2 comes with 12 USD but it’s empty.

You either select the existing H2 tag added and change their value, or go for a small hacky way and comment out the code test provides. It passes.

Thanks, making sense now!