Skip to content

Instantly share code, notes, and snippets.

@thmain
Created December 25, 2022 05:30
Show Gist options
  • Save thmain/ba873eec46feafe34bac94b1c1792c2c to your computer and use it in GitHub Desktop.
Save thmain/ba873eec46feafe34bac94b1c1792c2c to your computer and use it in GitHub Desktop.
'use strict';
function predicate() {
var newReleases = [{
"id": 70111470,
"title": "Die Hard",
"rating": 4.0
}, {
"id": 654356453,
"title": "Bad Boys",
"rating": 5.0
}, {
"id": 65432445,
"title": "The Chamber",
"rating": 4.0
}, {
"id": 675465,
"title": "Fracture",
"rating": 5.0
}];
var result = [];
newReleases.forEach(function(video) {
return video.rating === 5.0 ? result.push(video) : null;
});
return result;
}
console.log(predicate());
/*
[
{id: 654356453, title: "Bad Boys"},
{id: 675465, title: "Fracture"}
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment