Create a Bar for Each Data Point in the Set help here

Tell us what’s happening:

Your code so far

    const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];
    const w = 500;
    const h = 100;
    const svg ="body")
                  .attr("width", w)
                  .attr("height", h);
       // Add your code below this line
       // Add your code above this line
       .attr("x", 0)
       .attr("y", 0)
       .attr("width", 25)
       .attr("height", 100);

Your browser information:

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

Link to the challenge:

You want to add the ‘rect’ element on the svg

it said me to add 9 rect how it can be done or I need to append 9 times

when you use the .data() function it will behave similar to .forEach().

.data(dataset) — Counts and parses the data values. There are nine values in our data set, so everything past this point is executed nine times, once for each value.

but constaintly am getting these

Your document should have 9 rect elements.

can you show me what code you have now?

same as i have pasted above no change

Okay,if you don’t mind me asking, why are you trying to append “svg”?

man you indirectly correct me man Thanks
You are awesome man

Lol. I was hoping you would see it. I’m glad you sorted it out!

1 Like