# Lodash clamp() re-creation - need help

In the capstone project Re-Creating the Lodash Library, https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash, I’m having difficulties, and am hoping someone can shed some light on this.

In recreating the `.clamp()` method exercises, I’m quite clear on the goal, and I coded what I thought was a correct, accurate re-creation. However, when I ran the test the first time, 2 of 4 passed. Then the lesson timed out (that really is an annoying “feature” of Codecademy by the way), and so when I started from scratch and wrote the code again and tested it, only 1 of 4 passed.

Here are the implementation steps listed in the lesson for the .clamp()` method recreation:

Implement : Let’s implement our game plan in code.

1. Add a method to our `_` object called `clamp` .
2. Add three parameters to this method: `number` , `lower` , and `upper` .
3. Within the method, create a variable called `lowerClampedValue` that is set equal to the return value of `Math.max()` called with `number` and `lower` .
4. Create a variable called `clampedValue` that is set equal to the return value of `Math.min()` called with `lowerClampedValue` and `upper` .
5. Return `clampedValue` as our final value from the method.

Once you’ve finished implementing this method, move on to the next step to test it.

Here is my code:

``````  clamp(num,upper,lower) {
const lowNum = Math.max(num,lower);
const clampNum = Math.min(num,upper);
return clampNum;
}
``````

And finally, here are the failed test statements:

Thanks for your feedback and insights.

print the inputs and outputs involved

nevermind, I just ran the tests again on the exact same code, and they all passed as (as expected)

it is wrong. maybe you changed it.

you are currently ignoring one of the three arguments passed to your function

imagine adding a and b together, but not using b to do so. that’s not going to be right.

1 Like

I did change it up, just a tiny bit…that’s all that was necessary. Ding ding ding!