Work with Dynamic Data in D3 4

Work with Dynamic Data in D3 4
0.0 0

#1

Tell us what’s happening:

Should I be changing the append instead? Im not sure what I am doing wrong.

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("h2")
      // Add your code below this line
      
      selection.text(("12 USD") => d)
      
      // 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/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/data-visualization/data-visualization-with-d3/work-with-dynamic-data-in-d3


#2

You have not defined variable named selection, so you can not use the text method on it.

You just need chain the text method right after the append line and then properly create an arrow function with the argument on the left side of the => and concatenate the argument’s value to " USD".

You may need to review arrow functions in the curriculum first.