I have a home video library with thumbnails and links to each video. I'd like to have a field to enter keywords and the library would only show the thumbnails of those matching the keywords based on the filename. If there are no keywords entered, then all videos show up. For example, if I type "trip to DC" and click "OK", then only those videos with "trip to DC" be displayed in the library. e.g. "trip to DC- national mall.mpg", "trip to DC- congress.mp4" would be displayed while others disappeared.
Thanks for any pointers.
You can create an array containing objects describing your videos, using filter() and includes() (You can also use match or search)
const videos = [
{
filename: "Trip to Dc bla bla",
thumbnail: "example.jpg",
link: "example.com"
},
{
filename: "Example 1",
thumbnail: "example.jpg",
link: "example.com"
},
{
filename: "Example 2",
thumbnail: "example.jpg",
link: "example.com"
}
];
const trip = videos.filter(video => {
return video.filename.includes("Trip");
})
console.log(trip);