title: How to iterate object in ejs?
body: <p>Good day! I'm a beginner at Node.js. I have a problem with an iterating object on ejs. I've used the book object to retrieve all data from DB and tried to pass it using res.locals. I will use the object to display the book information on the front-end. I tried several ways to iterate object that I've stored on middleware and I'm stuck on it (such as iterating the books by its length and using forEach).</p>
  <p>Middleware:</p>
  <pre><code>let book = await Book.find({});
  res.locals.book = {book};
  next();
  </code></pre>
  <p>EJS:</p>
  <pre><code>&lt;%if (book){%&gt;
      &lt;%for (var result in book){%&gt;
      &lt;li&gt;&lt;%=book%&gt;&lt;/li&gt; 
      &lt;li&gt;&lt;%=result%&gt;:&lt;%=book[result]%&gt;&lt;/li&gt;    
  &lt;%}%&gt;
  </code></pre>
  <p>Result:</p>
  <p><a href="https://i.stack.imgur.com/3h7Uk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3h7Uk.png" alt="enter image description here" /></a></p>
  <p>Is there another way to iterate and display it? Tyia!</p>