DEV Community

Discussion on: Stop using for loops. Here's why.

Collapse
 
macsikora profile image
Pragmatic Maciej • Edited

I would like to filter all those kind of articles.

To be clear I appreciate your effort, but radical attitudes saying that you should not use x or y is harmful. Lately there was such attitude for not using reduce, and I don't agree with that in the same way I don't agree with your article.

Also I think you are by intention making such clickbait title.

Collapse
 
jkhaui profile image
Jordy Lee
const filterClickbaitArticles = () => fetch('https://dev.to/api/articles')
  .then((response) => {
    return response.json();
  })
  .then((articles) => {
    const BAD_ARTICLE_REGEX = /(why)(\b\s.*\s\b)(is bad)/gi;

    return articles.filter(title => !BAD_ARTICLE_REGEX.test(title));
  });

Collapse
 
macsikora profile image
Pragmatic Maciej

Good one 😁