HELP M Chapter 4 Lab 2: Logical Operator

New to MongoDB and programming in general:

Chapter 4: Advanced CRUD Operations
Lab 2: Logic Operators

How many companies in the sample_training.companies dataset were either founded in 2004 and either have the social category_code or ‘web’ category_code, or were founded in the month of October and also either have the ‘social’ category_code or ‘web’ category_code?

Copy/paste the exact numeric value of the result that you get into the response field.

{$and: [
{$or: [{founded_month: 10}, {category_code: ‘social’}, {category_code:‘web’}]},
{$or: [{category_code: ‘social’}, {category_code: ‘web’}]}

Hi @Ghalib_Ansari,

If what we are trying to write is :

Find companies founded in the year 2004 or the month of October AND category code social or web.

Then I would try this :

<Removed, potential answer>

Hi @Ghalib_Ansari, welcome to the community.

Well, you are very close to the answer, just keep the following in mind:
The lab asks you to find the number of companies, which:

  • are either founded in the month of October OR in the year 2004


  • are having the category code as “social” OR “web”

I hope it helps. In case you have any doubts, please feel free to reach out to us.

Thanks. Regards.
Sourabh Bagrecha,
Curriculum Services Engineer.

Please do not post answer to quiz and lab. This prevents other learners the effort needed to learn.

Yes it would work, but you should look at:

Give a man a fish and you feed him for the day, teach a man to fish and you will feed him for the rest of his life.

This is why it is recommended not to publish University’s lab and quiz answer.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.