How would you use attr() here?

Tell us what’s happening:


I personally used style() to solve this assignment, however, I was just wondering how could one use attr() here instead since height and width are not stored in the svg style element and instead they are stored as constants?

Your code so far

svg {
  background-color: pink;
  const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

  const w = 500;
  const h = 100;

  const svg ="body")
  // Add your code below this line
                .style("width", w)
                .style("height", h)
  // Add your code above this line

Your browser information:

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

Challenge: Learn About SVG in D3

Link to the challenge: