• Custom User Avatar

    I want dat bod! Voted clever for the -tail.length

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    After reading some of the above posts, I added splice(0), but the tests are still failing. Now, every answer is still right, but now I'm getting "Expected: NaN, instead got..." What is the deal with these tests?

  • Custom User Avatar

    I also am seeing numbers interpretted in both directions in JavaScript in the final tests. The output prior to each test result, seems to me to be correct, and matches my answer, but doesn't match the expectation of the test.

    Example:
    Tests 0,0,1,1 ==> 3
    Expected: 12, instead got: 3

  • Custom User Avatar

    I wish I knew what was going on here, cow b

  • Custom User Avatar

    Rather than adding result to the condition, you should have just did break

  • Custom User Avatar

    This is not a valid solution! It passes only by accident, because the tests are badly written.

    Add this test and try again:
    Test.expect(![3, -1, 0, 2].all(isGreaterThanZero), 'One is less than zero');

    Hint, when you return in the middle of a loop, the loop stops, therefore only the first element is being checked.

  • Custom User Avatar

    You will also iterate any object properties on the array if you iterate in this way. Also, v is global now.

  • Custom User Avatar

    Using filter or forEach, while more succinct, is less efficient for this sort of thing, since these functions will continue until the entire array has been iterated, whereas a normal loop (or functions like every/some) can be broken as soon as an element is found that does not meet the criteria.

  • Custom User Avatar

    This is unsafe array iteration. It works in this case, but in general it is bad practice. If the array has any non-numeric properties, this will iterate those as well.