Data Visualization with D3 - Change Styles Based on Data

Tell us what’s happening:

i am trying to use a simple if statement. please can someone tell me what im 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')
      .text(d => d + ' USD');.style("color", (d) => {
        if (d < 20){
          return 'red'
        }
        else {
          return 'green'
        }
      })

  </script>
</body>

Your browser information:

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

Challenge Information:

Data Visualization with D3 - Change Styles Based on Data

Are you getting an error message in the console?

return needs to be used within a function only.

do you think you can concatenate a method to a semicolon?

please could you explain further

My mistake, it is in a function :face_with_monocle: You can disregard my comment, sorry.