A more elegant solution? Work with Dynamic Data in D3

Tell us what’s happening:

Hey everyone! Hope you’re well :slight_smile:

I’ve checked the forums and seen a few ways to get passed this challenge, but they all look rather hacky. Can anyone please tell me how I could concatenate the " USD" onto my h2 tags with a simple and elegant solution?

Thanks in advance!

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
      
      .text((d) => d).concat();
      
      // Add your code above this line
  </script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) 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

Hey Randell :slight_smile: I tried to delete this post moments after I wrote it but I couldn’t figure out how :joy: I was being stupid, the answer was super obvious. The thing I tried first was correct, I just screwed up the brackets the first time.

Thanks for your reply!