Final JS: Question 7

Does anybody else think that there’s more than one correct answer in question 7?

I also checked the queries in mongo compass and two of the queries returned me 4th and 5th results.
What am I missing??

Tnx,

No, I don’t think so. If you want only the 4th and 5th tallest people then you’re looking for an answer which will return an exact number of documents, and there’s only one answer which will return exactly that number of documents.

Are you sure???

As I said I’ve checked the queries in compass app and for …skip(3).limit(2) and …limit(5).skip(3), both of them returned me exactly 2 documents.
And it also makes sense because for (1) skip(3).limit(2) we’re skipping the first 3 tallest ppl, leaving us with 4th, 5th, 6th… and so on, by limit it to 2 we’re only getting the 4th and 5th tallest ppl.
And for (2) limit(5).skip(3) we’re limiting to get only the five tallest ppl and by skip(3) we’re ignoring the first 3 ppl leaving us with the 4th and the 5th tallest ppl.

I’m really confused…

100% sure. The question didn’t tell us what documents are in the collection or how many there are, only the shape of the documents. To try this out using Compass you must have created a collection and made up some documents to populate it with. And for the documents currently in your collection, two of the answers both return the right number of documents, but only one of them will always return the right number of documents regardless of how many documents there are in the collection or what those documents are.

Sorry, I really can’t say any more without giving you the answer. Just think carefully about the words in bold above and that should lead you in the right direction.

Good luck :crossed_fingers:

1 Like