gistlib
index.tsxconst search = (arr, target) => { let results = []; for (let i = 0; i < arr.length; i++) { if (arr[i].includes(target)) { results.push(arr[i]); } } return results; } const array = ['apple', 'banana', 'orange', 'grape', 'pear']; const searchTerm = 'app'; const searchResults = search(array, searchTerm); console.log(searchResults); 387 chars18 lines
const search = (arr, target) => { let results = []; for (let i = 0; i < arr.length; i++) { if (arr[i].includes(target)) { results.push(arr[i]); } } return results; } const array = ['apple', 'banana', 'orange', 'grape', 'pear']; const searchTerm = 'app'; const searchResults = search(array, searchTerm); console.log(searchResults);
gistlibby LogSnag