Why is this failing?

Tell us what’s happening:
It’s telling me that all of my h2s aren’t red and green? But they are, they’re all the right color. I copy pasted the solution and it’s still telling me I’m wrong. Please advise.

  **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"))
    // Add your code below this line
    .style("color", (d) => {
      if (d < 20){
        return 'red'
      }
      else {
        return 'green'
      }
    })


    // 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/91.0.4472.124 Safari/537.36

Challenge: Change Styles Based on Data

Link to the challenge:

HI @lilleboejada !

Welcome to the forum!

The code you have shared works on my end. Please ensure that you have disabled any extensions that interface with the freeCodeCamp website (such as Dark Mode and Ad Blocker), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.

Ohhhh that makes sense. Thank you!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.