I need to write a swapping function. Assume an example input of [1,2]. This is what I have right now:
function swapValues() {
var args = Array.prototype.slice.call(arguments);
console.log(args[0]);
var temp = args[0];
args[0] = args[1];
args[1] = temp;
return args;
}
I'm not getting the desired swap functionality, so I put the console.log statement in to see what is happening. The problem is I'm getting [1 , 2] printed to the console, but I'm only expecting one. The values returned are not swapped.