Why gives "b"? Why not "a"

Why gives "b"? Why not "a" https://code.sololearn.com/WNXN3PEVOVyJ/?ref=app

4/8/2020 8:34:25 AM


4 Answers

New Answer


x && y: if x evaluates to false, no need to test further, return x (as it's false) else if x evaluates to true, the result totally depends on y, so just return y (no need to test if y evaluates to true or false, just return it) in your case, both "a" and "b" are evaluated to true, so we are in the second hypothesis. it just returns "b"!


Have you tried switching them or adding new strings like c d e...? Try it, I'm sure you'll find the answer.


Thanks.. I got it 🤘


because both expression are considered truth,so it return the last expression