Check if three arrays contains the same element
Your code assumes that each of the 3 arrays is sorted. Otherwise the &lt; operator would not work. It's ok to assume this. You should have mentioned this in your question.

You use the == operator for comparing the numbers and the lengths. You should better use the === since the == operator considers 0 and "0" equal, which is not good in most cases.

It does not matter which of the 3 arrays comes first. The result will always be the same. Therefore it would be nice if the code looked the same for each of the 3 arrays. Your current code looks different for arr3.

I would write the code differently:

function smallestCommonElement(a, b, c) {
    let i = 0, j = 0, k = 0;

    while (i &lt; a.length &amp;&amp; j &lt; b.length &amp;&amp; k &lt; c.length) {
        const max = Math.max(a[i], b[j], c[k]);

        let same = true;
        while (i &lt; a.length &amp;&amp; a[i] &lt; max) i++, same = false;
        while (j &lt; b.length &amp;&amp; b[j] &lt; max) j++, same = false;
        while (k &lt; c.length &amp;&amp; c[k] &lt; max) k++, same = false;

        if (same)
            return a[i];
    }
    return null;
}


The idea is to start at the beginning of the arrays. In each step, look at the current values and find the maximum number. Advance each array to this maximum number. If none of the 3 arrays has been advanced, this means that the current values from all the arrays must be the same. In that case, return this value. Otherwise the values must be different, so try again. Do all this until one of the arrays is at the end, in which case there is no common element.



Looking again at your code, there is a bug. Given the arrays [2, 3], [2, 3], [3], your code will return 'No equal number' even though the 3 appears in each array. Using a debugger (or pen and paper), you should step through your code to see where the bug is.

It's an edge case, and it happens in the part of the code that differs from the other parts. That's why I suggested that the code for all 3 arrays should look the same. It's one less chance of introducing bugs.