Question about implicit if/else Javascript

Hello FCC campers, someone can answer my questions ?
In Javascript !

1-Can we put multiple instructions in the implicit if/else ?
2-With implicit if/else, can we use multiple AND (&&) and OR (||) in the condition part ?

if yes why ? & if no why ?
Thank you in advance

Can you explain what you mean here with some examples if what you want to do/how you think this works? Particularly what you mean by “implicit if/else”?

Is is that you can leave off the else in many situations? Like this:

function example (thing) {
  if (thing) {
    return "thing is truthy";
  }
  return "thing is not truthy";
}

Being the same as this:

function example (thing) {
  if (thing) {
    return "thing is truthy";
  } else {
    return "thing is not truthy";
  }
}

Because there isn’t anything special there except that you can leave off the else. Which is logical: you have a function that returns one result if a something is true: the function exits at that point. But if the something is false, the program ignores the if block and just carries on.

It doesn’t change anything else: not how it works, not any of the syntax apart from that. It’s just a convenience, to take into account that it’s extremely common to only need the if/if else part of a conditional statement and not care about else.

My excuse, thank you for your time and answer, by implicit i mean ternary condition !! (Y) ? E : D;

I’ve never heard that called an implicit if else. That’s quite confusing terminology, as it’s not implicit, it’s extremely explicit. Anyway

Yes, the condition is just an expression that evaluates to true or false, doesn’t matter what it consists of.

What do you mean? As in like if/if else/if else/if else/else? Cos you can nest ternaries as much as you want, they’re just going to evaluate to some value

condition1
? "foo"
: condition2
? "bar"
: condition3
? "baz"
: "quux"

That’ll work fine, it’s just normally extremely hard to read vs. just using if/if else/if else/else.

1 Like

That’s the answers am looking for !! thank you so much for your time & your help !!