So my code works just fine and passes the tests. However, I’m struggling to get my head around why setting the style on each div doesn’t result in all of them being the same. If you’re changing the style for each of the divs then how come they don’t all end up being the same height as the last value in the dataset? If they all have the same class of “bar”, then how come they don’t all become 9px in height if 9 is the last element in the array when the class should be applied to them all, if you see where I’m coming from.
Tell us what’s happening:
**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", (h) => h + "px")
// Add your code above this line
</script>
</body>
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
.
Challenge: Update the Height of an Element Dynamically
Link to the challenge: