I’m currently working on the lodash project in the full stack engineering course. I’m stuck on step 10.
Whenever I test the code, I keep getting an error stating that inRange isn’t defined. Here’'s my code. What am I doing wrong?
const _={
clamp(number,lower,upper){
var lowerClampedValue = Math.max(number, lower);
var clampedValue = Math.min(lowerClampedValue, upper);
return clampedValue;
},
inRange(number,start,end){
if(end === undefined){
end = start
start = 0
}
if(start < node end){
var temp = end
end = start
start = temp
}
var isinRange = start <=number && number< end
return isInRange
}
mirja_t
February 10, 2022, 9:13pm
#2
Does it say inRange isn’t defined or isInRange isn’t defined?
I assume the latter, right? Find where it is defined (or where it should be).
mtf
February 10, 2022, 9:24pm
#3
neelaroon0339864328:
if(start < node end){
Also, where is node
defined?
The message I’m getting says that inRange isn’t defined. Is the problem that node isn’t defined?
mtf
February 10, 2022, 10:42pm
#5
It looks like inRange
is defined, but isinRange
is not, and neither is node
.
mirja_t
February 10, 2022, 10:42pm
#6
node isn’t defined (and it is the wrong syntax for a condition anyway, what should that do?)
and isInRange isn’t defined. Both is a problem.
mirja_t
February 10, 2022, 10:44pm
#7
mtf:
but isinRange
is not
That is defined. isInRange
isn’t.
1 Like
This is the message I get in terminal:
1 - _.inRange() is defined - Failed: _.inRange() was not properly defined.
Terminating tests…
How do I fix the code?
mirja_t
February 11, 2022, 8:40pm
#9
Have you tried to correct the two errors we showed you?
From what we see, inRange is properly defined. But there are problems within the method that may cause this – not very precise – error message.
I’ve been trying to fix the two errors but I keep getting a message stating inRange isn’t properly defined.
mtf
February 11, 2022, 10:03pm
#11
The first thing to do is copy all your code, then start with just the method definition…
},
inRange(number, start, end) {
return number;
}
Now run the test and you should get a check mark for inRange
is defined. Let us know when you get to this point.
1 Like
system
closed
March 25, 2022, 2:04pm
#12
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.