Filtering an object JS I'm making a news aggregator using newsAPI, and have everything working - to begin with. But was wondering if the code I use to filter through an object can be made more efficient - meaning fewer lines of code. 

So far, it only returns what I need from the raw JSON file, then filters it using a for loop to ignore objects with blank values.

Any help would be great.

   if (!error &amp;&amp; response.statusCode == 200) {

        let data = JSON.parse(body);

        let articles = data.articles.map(article =&gt; {
            return {
                "title": article.title,
                "date": article.publishedAt,
                "image": article.urlToImage,
                "description": article.description,
                "link": article.url
            }
        });

        let filtered = []
        for (let i = 0; i &lt; articles.length; i++) {
            if (articles[i].title !== null &amp;&amp;
                articles[i].date !== null &amp;&amp;
                articles[i].image !== null &amp;&amp;
                articles[i].description !== null &amp;&amp;
                articles[i].link !== null) {
                filtered.push(articles[i])
            }
        }

        console.log(filtered)

        res.render("index", { filtered: filtered });

   }
let -> const
Use the Array methods (filter, every)
Use object destructuring
Use object short-hand
Use a method for the null check so you don't have to write it for every property


if (!error &amp;&amp; response.statusCode == 200) {
  const data = JSON.parse(body);

  const filtered = data.articles
    .filter(({ title, publishedAt, urlToImage, description, url }) =&gt;
      [title, publishedAt, urlToImage, description, url].every(
        prop =&gt; prop !== null
      )
    )
    .map(
      ({
        title,
        publishedAt: date,
        urlToImage: image,
        description,
        url: link
      }) =&gt; ({
        title,
        date,
        image,
        description,
        link
      })
    );

  res.render("index", { filtered });
}


Update: filtered first for lower memory consumption as by @FreezePhoenix suggestion.