цикл лишний ...
var names = ["Kurt", "Dave", "Kris", "Pat", "Steve"]
function nextPerson(a) {
return a != +a ? (a = names.indexOf(a) + 1, [a *= 2, --a].reverse())
: (a % 2 && ++a, a = (a - 2) / 2 % names.length, names[a]) };
alert ( nextPerson ( 17 ) );
alert ( nextPerson ( 18 ) );
alert ( nextPerson ( "Pat" ) );
names.push( "Richard" );
alert ( nextPerson ( "Richard" ) );