The latest JSLint also warn about the use of assignations inside guards. One way to avoid the double `currentElement = queue.shift()` would be to use a do-while, with `currentElement = queue.shift()` as the first statement and and if guard for the rest of the code. Or check for the queue.length in the while guard and make `currentElement = queue.shift()` the first statement if each current element is valid when there is one in the queue.