Why doesnt my code work in lodash InRange(

it says syntax error in inRange (ignore clamp)

const _ = {

   clamp(number, lower, higher) {
     var num = Math.max(number,lower);
     var hnum = Math.min(num, higher);
     return hnum;
   }
   
  
   
   inRange(number, start, end){
     if (end === undefined) {
     end = start;
     start = 0;
     temp === end;
    } if (end < start) {
      var temp = end;
       end = start;
       start = temp;
     };
      var isInRange = start <= number && number < end;
       return isInRange;
        }; 
       };



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


I think in the if statement there are 2 if instead of 1 if and 1 else

After creating the first method you need to put a comma next to the close curly bracket }.

1 Like