Lodash inRange problem

I am having the problem with the start being greater than the end. The funny thing is. I tested my code elsewhere and it should work, but it is being rejected. Of all the test conditions, it is the only one that is turning up negative. It is frustrating because it all should work, but it isn’t for some reason… here is my entire inRange code.

inRange(x, start, end){

if(end === undefined){

  end = start;

  start = 0;

}if(start > end){

  start = end

  let temp = end

  end = start

  start = temp

}if (x < start){

  return false

}if (x >= end){

  return false

}else{

  return true

}

}

Here are the test results:

Blockquote
_.inRange() Tests:
1 - _.inRange() is defined - Passed!
2 - Returns true if an in-range value is in range - Passed!
3 - Returns false if a too small value is out of range - Passed!
4 - Returns false if a too large value is out of range - Passed!
5 - Uses end value as start value and start value as 0 if end value is not defined - Passed!
6 - Reverses start and end values if start is bigger than end - Failed: _.inRange(3, 4, 2) returned false instead of true.
7 - Returns true if provided value is same as start value - Passed!
8 - Returns false if provided value is same as end value - Passed!

That will overwrite start if you haven’t first stored it in a temporary variable.

const temp = start
start = end
end = temp

Similar to how we can swap in Python,

a, b = b, a

we can use destructuring to swap in ES,

[a, b] = [b, a]