Re-creating the lodash library - project


I am trying to complete the final project from “Introduction to JavaScript”. This project is called: RE-CREATING THE LODASH LIBRARY.

I am stuck at item 6. In this project there is no “hint” or video to help, which make it very difficult.

After running node test/clamp.js on the Terminal, I am getting an error saying that there is a syntax error in line 13 => module.exports = _;

But this is a code that CodeCademy commented not to modify. What should I do?

// Do not write or modify code below this line.
module.exports = _;


Hey man, so I was stuck for a few minutes on this until I realized I hadn’t saved my code. I know it might seem silly but make sure that you are saving your code before running the test. If your code looks like what I have below then it should pass the test!

const _ = {
  clamp(number, lower, upper) {
    const lowerClampedValue = Math.max(number, lower);
    const clampedValue = Math.min(lowerClampedValue, upper);
    return clampedValue;

// Do not write or modify code below this line.
module.exports = _ ;


Hi. I’ve saved the code and the problem persists. My code is the same as yours. Take a look at the attached image, please, and see if you can find what might be wrong.


Hey man it looks like you’re missing a closing bracket thats all. you have this:
let _ = { clamp(number, lower, upper) { let lowerClampedValue = Math.max(number, lower); let clampedValue = Math.min(lowerClampedValue, upper); return clampedValue; }

After return clampedValue you should something like this

    return clampedValue;


Also I would refrain from using let to set “_” since it shouldn’t be changed later on. Your code will work but it’s not wise to use “let” everywhere. Remember use “const” when a variable’s value should not be changed and only use “var” or “let” when you know your variable may be changing later on.


Wow, that’s true. Now it’s working. Thank you a lot for all your help. It’s amazing how I didn’t see this.