Https://www.freecodecamp.org/learn/data-visualization/data-visualization-with-d3/add-classes-with-d3

Tell us what’s happening:

I can’t figure out the correct answer. Any help?

Your code so far


<style>
.bar {
  width: 25px;
  height: 100px;
  display: inline-block;
  background-color: blue;
}
</style>
<body>
<script>
  const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

  d3.select("body").selectAll("div")
    .data(dataset)
    .enter()
    .append("div")
    // Add your code below this line
d3.attr("bar", "div");


    // 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/85.0.4183.83 Safari/537.36.

Challenge: Add Classes with D3

Link to the challenge:

Hello there,

You almost got it.

Hint: The attr method is used the same as the append method.

Hope this helps

So please what is the correct answer?

I will not give you the answer directly, but am willing to help walk you through whatever is currently confusing you.

Think about what you did in the previous lesson:

I figured it out. Thanks

1 Like

please i didn’t get it am the beginner so you can show me the proccess

Solution found in a google search. Search about .attr()