Lodash clamp method

Hello, I can’t seem to figure this out after hours of trying. I have tried 5 ways and this seems to be the closest I have gotten. It passes all tests besides 4 - Clamps values by upper bound - Failed: _.clamp(5, 1, 3) returned 5 instead of 3.

Thank you for any help!

const _ = {

  clamp (number, lower, upper)  {

    const lowerClampedValue = Math.max(number, lower);

    const clampedValue = Math.min(lowerClampedValue, upper);

    return lowerClampedValue



I think this might just be an issue of what you’re returning - there should be a different value that you could return to fix your issue! :wink:

1 Like

I swear I tried returning just clampedValue before! oh well, it works now :slight_smile: Thank you!

1 Like