title: How do I check every element in an array to see if its present in another array, and to replace the element in first array to something else?
body: <p>I want to make a function that has two arrays in it. The first array contains numbers and the 2nd contains letters and numbers. I want to compare them, and if a certain element within the 2nd array is also on the 1st array, then to replace the element of the 1st array to something else. This is the example array i've written:</p>
  <pre><code>const array1 = ['1', '2', '3', '4', '5']
  const array2 = ['a', 'b' '3', '2', 'c']
  </code></pre>
  <p>So the 2nd array and the 1st array both have numbers 3 and 2. This is my code for trying to compare the values:</p>
  <pre><code>const arraycompare = array1.some(x =&gt; array2.includes(x))
  const finalarray = array1.replace(arraycompare, `${arraycompare} - also found in array2`
  console.log(finalarray)
  </code></pre>
  <p>However this doesn't work because arraycompare returns a boolean and not the value of the elements that it had compared and found that they are present in both arrays.
  So how am I supposted to fix this and make it so that arraycompare and finalarray work?</p>