Update the Height of an Element Dynamically

Update the Height of an Element Dynamically
0.0 0

#1

This code passed just one test. I don’t know what went wrong

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'  ); // Maybe something is wrong here 
      
      
      // Add your code above this line
  </script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

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


#2

I tried this and it worked:
.style(“height”, (d) => ${d}px );

Here, I’ve used string literals to add ‘px’ to the value of d.
Hope this helps :slight_smile:


#3

I tried it but this is not working


#4

Try resetting the code and then try again.


#5

Still not working.:disappointed:


#6

mine neither. is this ${d} syntax supposed to be working in D3? I know this is a jQuery syntax though.