Contact: aviboots(AT)netvision.net.il
39,954 questions
51,896 answers
573 users
const array = ['c++', 'typescript', 'c', 'java']; const substring = 'script'; const match = array.find(element => { if (element.includes(substring)) { return true; } return false; }); console.log(match); /* run: "typescript" */
const array = ['c++', 'typescript', 'c', 'java']; const substring = 'script'; const index = array.findIndex(element => { if (element.includes(substring)) { return true; } return false; }); console.log(index); /* run: 1 */