Howdy. I don't think there was any code posted, just a question about ?:
If/else statements work fine and technically isn't "||" essentially just a shortcut of doing the same?
Yep regarding if/else, and in certain situations || results in the same thing but does it very differently.
I only ask because I feel like leaving the option of "||" as the only correct answer to this exercise limits or restricts our abilities to code our own ways.
Mayhaps (that's a word! or at least was 200 years ago. I declare thee a word.)
Depends on context.
But I used if/else in my most recent solution, and this is a pretty well done course in terms of checking code's results. Pretty sure it accepts at least some, if not all reasonable if/else ones.
That being said, I was happy to learn the ability to use the "||" and will continue to do so ...
Yeah. It's a bit cryptic, but does illustrate how logical or, expressions and short-circuiting work.
And it's used tons in industry.
A small few I would assume, and they'd know what they're talking about, would prefer if else in many situations (perhaps ?: too) as it's more understandable. And in general, speed in these cases is a negligible consideration.
No worries at all for sharing, I think the discussion especially you started is important, and it's a qualified, obviously constructive post, which is always welcome.