I'm a TA and a student came in asking why the following code didn't swap the first 2 elements in an array and instead resulted as undefined. Here's the code the student showed me:
var swapFirstTwoElementsOf = function (a) {
a = [a[1],a[0]].concat(a.slice(2, a.length));
}
Why does this return undefined?