Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

40 lines
663 B
Markdown

---
title: Set a Domain and a Range on a Scale
---
# Set a Domain and a Range on a Scale
---
## Hints
### Hint 1
Use the `.domain()` and `.range()` functions.
### Hint 2
Both the the `.domain()` and `.range()` functions accept an array of two elements.
---
## Solutions
The `domain` and `range` functions can be chained, and the following is the solution:
<details><summary>Solution 1 (Click to Show/Hide)</summary>
```html
<body>
<script>
const scale = d3.scaleLinear()
.domain([250, 500])
.range([10, 150]);
const output = scale(50);
d3.select("body")
.append("h2")
.text(output);
</script>
</body>
```
</details>