I’m currently completing an assignment where I need to pass the following test
* should work on an arguments object
Here is my code.
function first (array, n) {
var result = [];
if (Array.isArray(array)) {
if (n && n > 0) {
var number = n > array.length ? array.length : n;
for (var i=0; i < number; i++) {
result.push(array[i]);
}
} else {
result.push(array[0]);
}
return result;
} else {
return result;
}
};
Im not sure what lines I need to ammend to make it pass this test, can anyone help me?