Rotating `n` random items in an array
First of all, I wouldn't call it "rotate" as rotate has a significant meaning in programming. What you're doing though is picking up n random values and rotating them by themselves, and not in context to the array itself.

Anyways, I'll just explain in the code for the rest.



function rotate(arr, n){

  // I wouldn't want to mutate the original array in the operation
  // so instead I operate on a shallow copy of the array.
  var arrToOperate = arr.slice();
  
  // Then we select indices by random.
  // The | 0 at the end truncates the decimal part, like floor.
  // We sort, since rotation needs to know who is last/first.
  var selectedIndices = [];
  for(var i = n; i--;) selectedIndices.push((Math.random()*arr.length) | 0);
  selectedIndices.sort();

  // Now the actual rotation. If value isn't the zeroth number, get the next
  // otherwise get the one from the other end.
  for(var j = n; j--;) arrToOperate[selectedIndices[j]] = arr[selectedIndices[(!j ? n : j) - 1]];

  return arrToOperate;

}

alert(JSON.stringify(rotate([10,20,30,40,50,60], 3)));




Looping backwards is personal preference, because I don't have to use comparison operators, and I can always use 0 as the terminator value.

The | 0 is also a personal preference, as it is shorter (and sometimes faster) than Math.floor.