Challenge 13 Megathread

Welcome to challenge #13!

Use this thread for any and all questions relating to challenge 13


Same question as the one with the last. does it count as within if the value is the same as the min or max.

So far mine counts it as false if the value is the same as min or max.

I have it as min and max inclusive. The way I see it is that it’s the minimum value the gauge can be at or the maximum value the gauge can be at.

That makes sense as well, I just think that should be a bit clearer. Thx anyways

Hi there!

Should be inclusive, however tests support both inclusive and exclusive to match the original challenge. A note has been added to the hint section about this.

Thanks for pointing it out!


I can’t find any errors in my code, yet fail on the last test case. Any thoughts?

Code should iterate through the array, do nothing if the code is good, otherwise return false. At the end if, the code hasn’t returned yet, it should return true.

But I seem to be overlooking something or another

It might be caused by the empty if statement. try doing if !() and write "return false in the if statement block to get rid of else altogether, see if that works

1 Like

Nice, thx for the fast update.


Still no dice. Did you get it to work?

Hint: Try to figure out what i is using console.log()

1 Like

I used different code that works. For you i is not returning the individual objects in the object list a. Its returning the index for them. 0, 1 and so on. so u need to a[i] to get the objects at the spot. if you want the object you can try something like .every but then you would need to do some more things to break out of that loop.
And like the person above me said. always try console.log() when things dont work

1 Like

Look up the difference between for…in and for…of in JavaScript. That might help.

1 Like

any idea where i went wrong

I think what’s happening in your code is that your function is returning a value of true the first instance your loop finds a gauge that is greater than the min, and less than the max. So it’s not checking the rest of the array whether the rest of the gauges also meet the criteria.

Basically, a return statement will interrupt the loop from continuing onwards, so you need to find a way to return true only if all of the gauges are in threshold.


This should return an array of booleans, I think it has to return one boolean depending on all the gauges?

1 Like

For a different approach to the solution, you can look at the some() function added with reverse logic.


First thing, you’re using “i” as a counter, but I don’t see you accessing the gaugeList index.

so, gaugeList[i].current vs gaugeList.current

Second thing, if you use “&&” aka AND, both tests have to fail in order to return false, but in reality only ONE test has to fail, so a different comparison operator should be used.


PS you should return true only AFTER checking all the values, right now you are returning true right away on first check


const checkAllGauges = (gaugeList) => {
var result = true;
for (g of gaugeList) { result &&= (g.current > g.min && g.current < g.max) }
return result;

This is completley valid code but your parser does not want to accept it. &&= is the issue here, in VS code it runs fine because its valid, on the challenge page it fails.

" If one of the values is outside the spec, return false, if they are all ok, return true. "
hint: avoid &&

1 Like