Data Visualization with D3: Update the Height of an Element Dynamically

Tell us what’s happening:

Running this code should work: it shows the bar chart but the test does not pass.

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")
      .attr("class", "bar")
      // Add your code below this line
      
         .style("height", (d) => d + "px")
      
      // 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/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/data-visualization/data-visualization-with-d3/update-the-height-of-an-element-dynamically

.style(“height”, (d) => { return d + “px”});

the above code also works (makes the bar chart per the data array) but FCC says it does not pass the test???

The only way I could get this to pass is in firefox. Will not work on chrome

I think you must use the attr method, not style. In fact, attr is the most used.