array some method
by Ken Sprague
JavaScript
//array some()
//wider availability than includes()
//functional approach like map, filter, and forEach
//returns Boolean when first positive match is found
let movies = ['Batman Dark Knight', 'Deadpool 2', 'Avengers', 'Iron Man', 'Spiderman', 'Superman', 'Swamp Thing', 'Ghost Rider', 'Daredevil', 'Ghost in a Shell', 'Akira', 'Gaurdians of the Galaxy', 'Aquaman', 'Wonder Woman', 'Deapool', 'Xmen'];
let keyword1 = 'Deadpool'; //appears more than once
let keyword2 = 'Ghost'; //appears once
let keyword3 = 'Max'; //not in list
let test1 = movies.some(function(title, index){
console.log(index,title);
return title.indexOf(keyword1) > -1;
});
let test2 = movies.some(function(title, index){
console.log(index,title);
return title.indexOf(keyword2) > -1;
});
let test3 = movies.some(function(title, index){
console.log(index,title);
return title.indexOf(keyword3) > -1;
});