Чем вы все отвечаете. Можете ли вы сказать мне, если сейчас я хочу отфильтровать массив, который содержит objectcts (файл JSON). Как мне сделать это правильно?
arrayPhotos = [{
"location": "Photos/_DSC0150.jpg",
"title": "Title001",
"id": "image_id_001",
"tags": [ "building", "city", "hotel"]
},
{
"location": "Photos/_DSC0226.jpg",
"title": "Title002",
"id": "image_id_002",
"tags": [ "fruit", "palm"]
},
{
"location": "Photos/_DSC0442.jpg",
"title": "Title003",
"id": "image_id_003",
"tags": [ "building" , "catedral" , "history"]
},
]
let inputFilter = $("#inputValue").val().toLowerCase();
filteredArrayPhotos = arrayPhotos.filter(function () {
//Here i need to check if some of the characters in the search field match the
// ones in `arrayPhotos` . And if they do , i want those images to added to
// `filteredArrayPhotos`
})
И у меня есть поле ввода поиска:
<input type="text" id="inputValue" placeholder="Type to search by name"></input>
<button onclick="filterImagesByName()" type="button">Search</button>