Yesterday, i asked a question about searching for arrays, i got an answer that contains the following code:
function searchDatabase(query) {
// For each object in array
for(var object of SampleArray) {
// Get list values of object
var lists = Object.values(object)
// For each list of object
for(var list of lists) {
// For each item of list
for(var item of list) {
// Look for item matching query. Locally convert to lower case to
// avoid case sensitivity issues
if(item.toLowerCase().indexOf(query.toLowerCase()) !== -1) {
return object
}
}
}
}
}
Here is my array
"Songs": [{
"title": "", "Source": "", "SongArt": "", "artist": "", "explicit": false
}]
I’m aiming to find a solution so i can search for a variable in the array like the “source”, and if it is found, then it will do a console.log(Found Variable);
Aucun commentaire:
Enregistrer un commentaire