Compare two Arrays and replace Duplicates with values from a third array
<pre><code>var array1 = ['a','b','c','d'];
var array2 = ['a','v','n','d','i','f'];

var array3 = ['1','2','3','4','5','6'];
</code></pre>

<p>Just starting to learn Javascript, I can't figure out how to compare the values of <code>array2</code> to those on <code>array1</code> and if so replace it with the corresponded array index from <code>array3</code>.</p>

<p>To turn it like this:</p>

<pre><code>array2 = ['1','v','n','4','i','f'];
</code></pre>

<p>But also, it has to compare the values from array1 and array2 even if the index positions are different like this:</p>

<pre><code>var array1 = ['a','b','c','d'];
var array2 = ['d','v','n','a','i','f'];
</code></pre>

<p>Thanks for the help</p>