freeCodeCamp/curriculum/challenges/arabic/04-data-visualization/data-visualization-with-d3/set-a-domain-and-a-range-on...

1.4 KiB

id title challengeType videoUrl localeTitle
587d7fac367417b2b2512bdb Set a Domain and a Range on a Scale 6

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'assert(code.match(/\.domain/g), "Your code should use the <code>domain()</code> method.");'
  - text: ''
    testString: 'assert(JSON.stringify(scale.domain()) == JSON.stringify([250, 500]), "The <code>domain()</code> of the scale should be set to <code>[250, 500]</code>.");'
  - text: ''
    testString: 'assert(code.match(/\.range/g), "Your code should use the <code>range()</code> method.");'
  - text: ''
    testString: 'assert(JSON.stringify(scale.range()) == JSON.stringify([10, 150]), "The <code>range()</code> of the scale should be set to <code>[10, 150]</code>.");'
  - text: ''
    testString: 'assert($("h2").text() == "-102", "The text in the <code>h2</code> should be -102.");'

Challenge Seed

<body>
  <script>
    // Add your code below this line
    const scale = d3.scaleLinear();



    // Add your code above this line
    const output = scale(50);
    d3.select("body")
      .append("h2")
      .text(output);
  </script>
</body>

Solution

// solution required