This is the most cumbersome part of this chapter. Assume we want to display only the famous stories (the ones with upvotes
greater than 20
). In order to achieve that we have to create a custom filter and apply it to filterBy
. We are going to create a filter named famous
which expects two parameters:
The array we want to filter
The bound which defines the amount of
upvotes
a story must have, in order to be considered as famous
The famous
filter returns an array which contains only the objects that satisfy a condition.
If you can't keep up with this example don't worry, you will get it sooner or later, just keep reading..
<html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> <title>Famous Stories</title> </head> <body> <div class="container"> <h1>Let's hear some famous stories!</h1> <ul class="list-group...