Search code examples
javascriptlodashlibraries

In Lodash library of JavaScript, why it swap start number with end number if the start number is greather than end number?


Lodash's inRange(number, startNumber, endNumber);

Can't understand why it swaps startNumber with endNumber, if startNumber is greater than endNumber? I read the documentation but still don't understand why.


Solution

  • It's syntactic sugaring. The functionality is to check whether a number is between two other numbers (start and end), regardless of which one of them is greater than the other.