inRange() lodash #5 failing

Hi one of test is failing and im not sure why. Thought the undefined if statement looked good. Can anyone explain what im doing wrong?
Link to lesson here: https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash

Error in bash: Uses end value as start value and start value as 0 if end value is not defined - Failed: _.inRange(1, 2) returned false instead of true.

inRange (num, start, end){
    if(end === 'undefined'){
      end = start;
      start = 0;
      
    }
    if(start > end){
      var tempEnd = end;
      end = start;
      start = tempEnd;
    }
    if(num >= end || num < start){
      return false;
    }else{
      return true;
    }
    
  }
1 Like

I think ‘undefined’ should not be a string, unless you’re checking for the string itself.

2 Likes

What @toastedpitabread said. You might be better off using the ! for logic here. For example:

 if(!end){
      end = start;
      start = 0;
    }
2 Likes

It worked. Thank you!

Thank you. That was my problem solver :cowboy_hat_face: +karma