Re:A Senior Engineer's Guide to the System Design Interview
by _dain_ on Friday March 03, 2023 @10:29AM
(#35010847)
I've never written a line of Javascript in my life.
a.filter(x=>1)
guessing that arrow looking thing is syntax sugar for a lambda that always returns a 1, then it's implicitly cast to boolean true in the filter, so nothing gets filtered out and b ends up just the same as a.
!!1
not not 1 -> true
b.some(e=>e>6)
at least one element of b greater than 6, clearly true
so both arms of the && are true, so foo() gets called every time.
I don't think this is a very good test if someone like me can pass it just by making educated guesses.
so both arms of the && are true, so foo() gets called every time.
I don't think this is a very good test if someone like me can pass it just by making educated guesses.