Hi!
I have a very basic question in my mind for the lodash project.
In the beginning of the project, it says “You will be implementing ten methods that add new functionality for numbers, strings, objects, and arrays.”
And then we’re given different methods such as .clamp(), .inRange() and so on.
For example let’s take .inRange() method. It can already make several things. So, why do we write some lines of codes which this method is already capable of? I mean, it can already compare, do greater or equal controls etc… So why do we add these again? Aren’t these inherited by the method’s nature? I’m quite confused…
It says:
"Here is a summary of the method:
-
.inRange()
takes three arguments: a number, a start value, and an end value -
.inRange()
checks to see if the provided number falls within the range specified by the start and end values - If the provided number is smaller than the start value,
.inRange()
will returnfalse
- If the provided number is larger than or equal to the end value,
.inRange()
will returnfalse
- If the provided number is within the start and end values,
.inRange()
will returntrue
- If no end value is provided to the method, the start value will be
0
and the end value will be the provided start value - If the provided start value is larger than the provided end value, the two values should be swapped"
.inRange() method is already capable of all of the above points. So why add the same controls to obtain these points?