Data Visualization - Change Styles Based on Data

Tell us what’s happening:
Describe your issue in detail here.
I don’t understand why my code is not working. I’m using the same code from the hint for this question. I thought maybe it was the indentations but those appear to be correct.

   **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/96.0.4664.110 Safari/537.36

Challenge: Change Styles Based on Data

Link to the challenge:

You’ve got some issues with your syntax:

You’ve got an extra right parens in there.

You’re missing a right curly brace here.

Totally missed that…thanks!!

For future reference, be sure to look at the console pane below the editor. It was displaying syntax error messages that pointed to these exact errors.

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