Check whether a number can be dialed on a phone keypad without diagonal moves
There are a lot of different traits you could optimize for.  I like to optimize for lines of code, so I'll try that.  

You can simplify the testing by building a "graph" (2-dimensional array) of reachable numbers.  Each row and column index is a phone digit.  If the value at (i,j) is true, then j is reachable from i.  

To do this, take all the numbers in each digit's row/column and create an array where those indexes have a value of 1.  

The reachability graph looks like this:



The digit 6 can reach 3,4,5,6,9 and you can see that reachable[6][x] is true for x=3,4,5,6 or 9.

Then simply run through the list of numbers and test if reachable[current][next] is true.

I've assumed the rook can dial repeated numbers like 3333.  If no, you can test for that in the graph creation or during reachability testing.



function rookTraversal(rows, phoneNumber) { 
    var cols=rows[0].map((col, i) =&gt; rows.map(row =&gt; row[i])),
        digits=phoneNumber.match(/(\d)/g),
        reachable=[];
    for (var row = 0; row &lt; rows.length; row++) {
        for (var col = 0; col &lt; cols.length; col++) {
            reachable[ rows[row][col] ] = rows[row].concat(cols[col]).reduce( (map, value) =&gt; { map[value]=1; return map }, [] );
        }
    }
    // console.log({reachable,digits});
    for (var i=0; i&lt;digits.length-1; ++i) if (! reachable[ digits[i] ][ digits[i+1] ]) return false;
    return true;
}

var data = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
];

console.log(rookTraversal(data, '4631782'));
console.log(rookTraversal(data, '4853267'));