Tell us what’s happening:
Hi All, I have a question. I dont understand why this is two snippets are giving different results. If someone knows, I would appreciate someone could explain it to me.
I realise the second version creates a copy, I just don’t get why the result is different?
function slasher(arr, howMany)
{
return arr.slice(howMany);
}
// result is [3]
function slasher(arr, howMany)
{
arr.slice(howMany);
return arr;
}
// result is [ 1, 2, 3 ]
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5
.
Link to the challenge: