FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

In Range

10mins

Implement a function inRange(number, start, end) that checks if a number falls between two numbers.

The function should:

  • Return true if number is greater than or equal to start and less than end.
  • If end is not provided, use 0 as the start and the provided value as end.
  • Swap start and end if start > end.

Examples

inRange(3, 2, 4); // true inRange(4, 8); // true, between 0 and 8 inRange(4, 2); // false, between 0 and 2 inRange(2, 2, 4); // true inRange(5, 2, 4); // false

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests