M121 Ch 1 Optional Lab

The solution given uses $gt and $size to check that the intersection of the directors, writers, and cast array is greater than zero. Next, it has us filtering the result to include only those values for which the computation is true.

Why not use just compute the intersection as a new projected field (labor_of_love) and then use the first hint given in the exercise to check that his is a non-empty array by using $elemMatch?

@jcarlosgarcia: I followed this approach and got the correct answer. I see no advantage to the official solution over mine. Any comments are appreciated.

< deleted >



Please follow Forum guidelines and do not post answers or potential answers or code here. I have edited your post to remove that.

Any valid solution works – I see no disadvantage to the recommended solution over what you propose. So long as it works, you can use what you want.

P.S. Juan Carlos is no longer the TA for this course. It’s best to just post your question without attempting to direct it to one or the other of us. FWIW.

I am interested in understanding, not getting the right answer. Can you comment on my post? What would be more idiomatic?

Note that this exercise was optional and took care to hide my answer so it wasn’t a spoiler. I read (perhaps from Juan Carlos) that it was OK to do that. I think we need to be more clear about policy and more welcoming to folks that are trying to comply with the rules.

Regards, afm

PS The link is here: [NOTICE] Please do not post potential answers in the forums

1 Like