Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Conditions in Jade/Pug

I am wondering whether or not this is possible in some way with jade.

I want to check if 2 ID's match and show/not show some jade html.. For example in jade

if user.posts === post._id
<!--show this-->
else 
<!--don't show anything-->

The 'posts' of the user are an array of objectIds, I want to check if one of those Ids matches the Id of the current post (post._id)

I am unsure how to go about this and I cannot find anything on stack.

Pug in the end is javascript as well so comparing an object to a string of course will never be equal

You could maybe try Array.protoype.indexOf()