Ad
  • Custom User Avatar

    Thanks for the feedback, will hadd those examples tomorrow.

  • Custom User Avatar

    Just had another try and random tests looking good. Last thing to do is to add some example test cases, the ones the user sees when trying to solve.

  • Custom User Avatar

    Thanks for your help, ive now added more test cases as well as random ones. Let me know if there is anything else I should improve

  • Custom User Avatar
  • Custom User Avatar

    As Daredevil mentioned, putting the length condition in the for loop is the problem.
    When you get an empty array in input, the for loop never runs! So, none of your return statements are called.
    The function returns undefined by default which leads to a failed test.

    Also, your function won't work on lists like [1, 3, 2]
    Because you return true as soon as you find an element being smaller than the next one instead of checking if all the elements satisfy this property.

  • Custom User Avatar

    You're attempting to iterate through an empty array, which seems to be the problem here. Be sure to use your conditional statement outside of the for-loop.