Does it fall in range?
- O(1) · Trivial
- Free
- Python
- JavaScript
- conditionals
- booleans
- comparisons
Problem
The bakery oven has to stay between two temperatures. Write a function that takes value, low and high, and returns true when the value falls inside that range.
Both ends count as inside: if low is 10 and high is 20, then 10 and 20 are in too. The numbers can be negative or have decimals.
Examples
15, 10, 20 → true
Too high
25, 10, 20 → false
Too low
5, 10, 20 → false
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def in_range(value, low, high):
passJavaScript
function inRange(value, low, high) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.
More O(1) challenges
- Does the photo fit the envelope?lists · conditionals · booleans
- How far apartoperations · comparisons
- How far from free shippingoperations · conditionals
- How far off is it?conditionals · comparisons · operations
- How many blocks you walklists · indexes · operations
- How many days in the month?lists · conditionals