I’m having trouble with my code for the JS algorithm challenge “Slasher Flick.” Here’s my code:
function slasher(arr, howMany) {
// it doesn't always pay to be first
var arrayRemain = arr.slice(howMany);
if (arr.length < howMany) {
return "[]";
} else if (arr.length >= howMany) {
return arrayRemain;
}
}
slasher([1, 2, 3], 9);
When howMany
is larger than the length of arr
, it returns []
like the test says it should. But when I run the code, it says that []
isn’t being returned like it should for this scenario.
Any help would be appreciated! I have a feeling I’m supposed to have a different way to return []
but I don’t know what that would be.