# freeCodeCamp Challenge Guide: Test if a Value Falls within a Specific Range

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-test-if-a-value-falls-within-a-specific-range/301598>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [August 3, 2019, 1:22pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-test-if-a-value-falls-within-a-specific-range/301598 "2019-08-03T13:22:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [August 3, 2019, 1:22pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-test-if-a-value-falls-within-a-specific-range/301598/1 "2019-08-03T13:22:07Z")

</div>

# [Test if a Value Falls within a Specific Range](https://www.freecodecamp.org/learn/quality-assurance/quality-assurance-and-testing-with-chai/test-if-a-value-falls-within-a-specific-range)

* * *

## Problem Explanation

To begin, locate the file “tests/1\_unit\_tests.js” and scroll to the suite of tests for ‘Comparisons’.

This file contains multiple suites of tests for the project, and this challenge requires you to make the tests in ` /** 10 */` pass.

* * *

## Hints

### Hint 1

`approximately()` requires a range to make the tests pass. The expected value for both tests is currently 1, so you need to find a range that allows for all values to be accounted for.

### Hint 2

Check the error outputs, and try to understand what the +/- values in the errors mean with respect to a possible range of values.

* * *

## Solutions

> **Solution 1 (Click to Show/Hide)**
>
> ```js
> / **10 - .approximately** /
> // .approximately(actual, expected, range, [message])
> // actual = expected +/- range
> // Choose the minimum range (3rd parameter) to make the test always pass
> // it should be less than 1
> test('#approximately', function() {
> assert.approximately(weirdNumbers(0.5), 1, /*edit this*/ 0.5);
> assert.approximately(weirdNumbers(0.2), 1, /*edit this*/ 0.8);
> });
> 
> ```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 8, 2025, 3:58pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-test-if-a-value-falls-within-a-specific-range/301598/2 "2025-01-08T15:58:00Z")

</div>

Closed on January 8, 2025, 3:58pm UTC


