2018-10-12 15:37:13 -04:00
---
title: Use the d3.max and d3.min Functions to Find Minimum and Maximum Values in a Dataset
---
2019-07-24 00:59:27 -07:00
# Use the d3.max and d3.min Functions to Find Minimum and Maximum Values in a Dataset
---
## Hints
2018-10-12 15:37:13 -04:00
2018-11-06 22:50:42 +05:30
### Hint 1
2018-10-12 15:37:13 -04:00
2018-11-06 22:50:42 +05:30
Use the `d3.max()` function.
2018-10-12 15:37:13 -04:00
2018-11-06 22:50:42 +05:30
### Hint 2
Use a callback function.
### Hint 3
Check for the second element in the callback function's array.
2019-07-24 00:59:27 -07:00
---
## Solutions
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-11-06 22:50:42 +05:30
To solve the solution, you code should look like this, this would check for the `z` co-ordinate i.e. the third element in the array which would be at an index of 2:
2019-07-24 00:59:27 -07:00
```html
2018-11-06 22:50:42 +05:30
< body >
< script >
const positionData = [[1, 7, -4],[6, 3, 8],[2, 8, 3]]
const output = d3.max(positionData, (d) => d[2]);
d3.select("body")
.append("h2")
.text(output)
< / script >
< / body >
```
2019-07-24 00:59:27 -07:00
< / details >