Answer does not exist

The answer is 33.

db.movieDetails.find({“genres”: “Western”}).count()

This query gives the answer 33 as it counts all the documents which have the genre “Western” listed as any element of the array.

However, the question asks for all the results which have the genre “Western” as the second element of genres array.

The query will look like this:

db.movieDetails.find({“genres.1”: “Western”}).count() //Since Arrays start from 0

or if you’re querying in compass then it’ll be {“genres.1”: “Western”}

Execute the query and you’ll find the answer.


@ [Yash_Pratap_03477] Oh! I see my error. You are right. Thank you. Deeply appreciated