+1

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

BangArray

4 Answers

New Answer

+7

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"!

+4

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

+1

Thanks.. I got it 🤘

+1

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