Lodash

Hello,

I have a problem with this exercise. I don´t understand why I have an error and why can create the method clamp by doing conditionals. Thank you

clamp (number, lower, higher) {

    if(number < lower) {

      return lower;

    } else if (number > higher){

      return higher;

    }    else {

      return number

    };

  }

};

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

What error are you getting?

I’m not completely sure (I haven’t learned JS), but it seems that you’ve got an extra }; after your else block.

2 Likes

That’s using the control flow approach. As @dr_victoria has pointed out, there is a stray curly brace at the end. Remove that and let us know what the test returns.

node test/clamp.js

Did you read the Ideate section? There is something new to learn there.

3 Likes