JSFiddle - React, Tailwind, and code Playground

by Igor Cuckovic

JavaScript

var a1 = ["arp", "live", "strong"]

var a2 = ["lively", "alive", "harp", "sharp", "armstrong"]

function inArray(array1 ,array2){
  var result = []
  
  array1.forEach(e1 => {
    array2.forEach(e2 => {
      if (e2.includes(e1)) {
      
      	console.log(e1, e2)
        result.push(e1)
      }
    })
  }) 
  
  return result
}

console.log(inArray(a1 ,a2))