Actually, never mind, I've got it. I swept the cobwebs from my mind and put it to work. Heres what I've come up with:
Code:
function swap(array,index1,index2) {
var firstRep = array[index1];
var secondRep = array[index2];
var output = new Array();
for (ar in array) {
if (ar==index1) {
output[index1] = secondRep;
} else if (ar==index2) {
output[index2] = firstRep;
} else {
output[ar] = array[ar];
}
}
return output;
}
function test() {
var output = "";
var start = new Array("a","b","c","d","e","f","g");
for (st in start) {
output += start[st];
}
alert(output);
output = "";
var newArray = swap(start,1,3);
for (ne in newArray) {
output += newArray[ne];
}
alert(output);
}