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:
upvotesa story must have, in order to be considered as famous
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 ...