Hi there, I’m dealing with this Exercise
I solved it with this code, which appeared to be quite right to me. But the terminal didn’t think so apparently.
inRange(number, start, end) {
if (number < start) {
return false;
} if (number >= end) {
return false;
} if (number >= start && number < end) {
return true;
} if (!end) {
end = start;
start = 0;
} if (start > end) {
var temp = end;
end = start;
start = temp;
}
},
};
Then after a huge amount of thoughts I checked out the video guide and apparently I just had to change the order like this:
inRange(number, start, end) {
if (!end) {
end = start;
start = 0;
} if (start > end) {
var temp = end;
end = start;
start = temp;
} if (number < start) {
return false;
} if (number >= end) {
return false;
} if (number >= start && number < end) {
return true;
}
},
};
Can anyone explain me what’s the real reason why the terminal didn’t agree with the first code?
Thanks