Lodash project

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 return false
  • If the provided number is larger than or equal to the end value, .inRange() will return false
  • If the provided number is within the start and end values, .inRange() will return true
  • 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?

Thanks
Link:https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash

Are you referring to actual lodash.js module or the method you are creating?

Actual lodash.js module.

Okay. We are given an opportunity to write this method from scratch without having referred to the actual module. It’s an exercise in ideation, design and implementation; practice that we do well to take a hand in. Dive in and try to create your method (as soon as you blot out the actual one from your memory).

I see.
So, we are supposed to create a method from scratch as if there exists no pre-defined method in lodash.js library.

Thank you.

1 Like