Re-creating the Lodash Library inRange


#1

I am getting an error when running
$ node test/in-range.js

Can anyone see what I doing wrong? Thank you.


#2

Your boolean function checking the range excludes the start value whilst the start value should be included. So in your case it should be:

if (value >= start && value < end) {
isInRange = true;
};

#3

Thank you for the help. That would have been a problem.

But it turns out that that was not what was giving me my error. It was the way I was checking if end was undefined. THanks for the help.


#4

Doh… It should have been undefined without the "" right?


#5

I actually just changed it to

if (!end) {

}

and that worked.