Challenge 3 Megathread

what does the || mean?

Hi pc2000,

I would check out this link on how to structure “if…else” statements.

Also, I’d suggest (although you can do it somewhat like what you did) to simply return true or false within either the IF statement or ELSE statement, for example:
return true

If you do assign true or false to answer no need to put it in quotes, if you do it will treat it like a string, you can just write our true or false.

Double check the hint on referencing objects. Take care!

2 Likes

Hi Robin,

Here is a good resource on ||

Also look up && as they are related!

3 Likes

Good Morning. It’s a gauge. Face it like a speed limit. Would you fine someone for being within the 40 km/h limit?
Have a great job today!

1 Like

It’s an OR operator. So if either both or one of the conditions on the left or right side of the operator are true, the function will return true.

heyyyy thanks for the hint!! Got it! :fire:

1 Like

Good Morning. Your “if” statement is incomplete (semantic fault). That’s why you’re receiving that error.
Have a good job!

1 Like

For all the people that completed challenge 2 but got the email saying they “missed challenge 2”, are we still eligible to win the finalist prizes?

} else {
answer = true;
}

It tells me "expected an identifier, instead saw else… What am I doing wrong with this syntax?

You might need to post your entire code snippet, this doesn’t really tell us where the issue could lie.

let answer;
if (guage.current < guage.min || guage.current > guage.max); {
answer = false;
} else {
answer = true;
}

I am stuck here…

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

Follow proper syntax and all should be good!
Doesn’t look like it matters whether you use greater than or equal to/ greater than.
Anyone know why calling the current part of the object is blue while min and max parts are white?

ah, you have a semicolon after your if statement which is syntactically incorrect.

2 Likes

GM! You have to satisfy both conditions in this case. Try replacing your OR || check with an AND && :slight_smile:

5 Likes

The boolean you return is incorrect, they should be all lowercase.

Why? are they blue and white

i believe “current” is a reserved word and has special meaning when used on its own. But after a variable name and a “.” it can be used as a property of an object. Good practice would be to avoid this completely and name your property something else, like gCurrent.

3 Likes

Thank you got it. true and false in correct syntax. Did anyone answer why the current was blue and the min and max stayed white?

@Sonicthecronic replied with an answer in this thread.