Tell us what’s happening:
The solution isn’t work
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; rv:74.0) Gecko/20100101 Firefox/74.0
.
Challenge: Change Styles Based on Data
Link to the challenge: