Challenge 3 Megathread

Hi Everyone can anyone give me a hand with understanding where I’m going wrong by looking at my code which is:

const checkGaugeStatus = (gauge) => {
// Code here!
let result;
if (gauge.current > gauge.max) {
result = “false”;
} else {
result = “true”;
return result;

Which returns two failed tests and:

Expected: true
Actual: true

Take a look at what you are actually returning. The test is expecting a type boolean value. It appears that actual and expected are the same but they are not they are different types.

1 Like

assuming this is in reply to my post, I don’t exactly follow/understand what you mean by they look the same but they aren’t? (granted I also don’t fully understand what a boolean value is but yeah) what’s the difference between the two expected and actual returned values?

Boolean is just true or false. When you put “true” it’s the word true stored and a string.

Hi Darth Maul,
Check out this documentation on the different JavaScript data types. "true" is not quite the same as true

Ok that makes more sense as to the key differences between boolean data and string (I assume) but what makes code give boolean responses rather than string? I don’t quite understand

Is there anyone who can explain to me what I’ve forgotten to get this message:
Failed: The checkGaugeStatus function should return the proper boolean
Reason: Your code ran but did not produce the correct result.
Hint: Make sure your formatting is matching what is expected!

const checkGaugeStatus = (gauge) => {
//console.log(gauge);// Code here!
if (gauge.current > gauge.min || gauge.current < gauge.max){//True
result = true;
result = false;}
return result;

Take a look at what values you are assigning to your result variable, which data-type are they?

&& not ||

wow… minimum 20 chars

Hi JeuxGaming,

I think the issue is probably in which operator you are using on the third line of your code. Read up on || is it the right choice to solve this problem?

Thank you very much, you were right

1 Like

There are different data types. Booleans and string are among them. There are only 2 values for booleans - true or false. (return true or return false) .On the other hand string values are usually placed inside ‘quotes’. (return “hello” , return “hello there”.) This is what your program is doing (return “true” or return “false”)

Tips: Firstly, in your code, make sure to check whether the current value falls within the range of min and max. Secondly, return Boolean data type (ex. return true). Thirdly, call the function from outside. Hope this helps.

check the spelling of your variables :slight_smile:

What was not initially apparent to me was that the statement:
(gauge.current > gauge.min && gauge.current < gauge.max)
in itself gives a Boolean true, which is what the test is looking for. There is no need for an if else.

1 Like

I did this but still have 1 test fail.
if(gauge.current > gauge.min && gauge.current < gauge.max);

return false;

try this
if(gauge.current > gauge.min && gauge.current < gauge.max) {
return true;

return false;


Good day! Your “if” is incomplete, verify the correct semantic.

JavaScript if else else if (

Have great work!!

1 Like

What I mean to say is there is no need for an if else or the need for any variables, no need for checking case either.

return(gauge.current > gauge.min && gauge.current < gauge.max);

this will return a Boolean variable, and satisfy both tests.


thank you. I am trying to get the hang of this. Hard for a newbie. LOL


I never worked with JavaScript in my life before Monday.
I program AutoCAD, and I tinker with Batch, PowerShell, and python.