---
id: 587d7fa8367417b2b2512bc9
title: Update the Height of an Element Dynamically
required:
- src: 'https://cdnjs.cloudflare.com/ajax/libs/d3/4.3.0/d3.min.js'
challengeType: 6
---
## Description
The previous challenges covered how to display data from an array and how to add CSS classes. You can combine these lessons to create a simple bar chart. There are two steps to this:
1) Create a div
for each data point in the array
2) Give each div
a dynamic height, using a callback function in the style()
method that sets height equal to the data value
Recall the format to set a style using a callback function:
selection.style("cssProperty", (d) => d)
## Instructions
Add the style()
method to the code in the editor to set the height
property for each element. Use a callback function to return the value of the data point with the string "px" added to it.
## Tests
```yml
tests:
- text: The first div
should have a height
of 12 pixels.
testString: assert($('div').eq(0).css('height') == '12px', 'The first div
should have a height
of 12 pixels.');
- text: The second div
should have a height
of 31 pixels.
testString: assert($('div').eq(1).css('height') == '31px', 'The second div
should have a height
of 31 pixels.');
- text: The third div
should have a height
of 22 pixels.
testString: assert($('div').eq(2).css('height') == '22px', 'The third div
should have a height
of 22 pixels.');
- text: The fourth div
should have a height
of 17 pixels.
testString: assert($('div').eq(3).css('height') == '17px', 'The fourth div
should have a height
of 17 pixels.');
- text: The fifth div
should have a height
of 25 pixels.
testString: assert($('div').eq(4).css('height') == '25px', 'The fifth div
should have a height
of 25 pixels.');
- text: The sixth div
should have a height
of 18 pixels.
testString: assert($('div').eq(5).css('height') == '18px', 'The sixth div
should have a height
of 18 pixels.');
- text: The seventh div
should have a height
of 29 pixels.
testString: assert($('div').eq(6).css('height') == '29px', 'The seventh div
should have a height
of 29 pixels.');
- text: The eighth div
should have a height
of 14 pixels.
testString: assert($('div').eq(7).css('height') == '14px', 'The eighth div
should have a height
of 14 pixels.');
- text: The ninth div
should have a height
of 9 pixels.
testString: assert($('div').eq(8).css('height') == '9px', 'The ninth div
should have a height
of 9 pixels.');
```
## Challenge Seed
## Solution
```js
// solution required
```