Ad
  • Custom User Avatar
  • Custom User Avatar

    finally starting to learn recursion for readability!

  • Default User Avatar

    Ahh I see. Awesome, thanks for your help!

  • Custom User Avatar

    And why aren't you returning in that case?

  • Default User Avatar

    haha! Thanks Chrono, you beat me to posting it!!

  • Default User Avatar

    Actually, think this is the problem (solution from user Mosef):

    For anyone having an issue because the tests/ final submission look like:
    
    There are 17 sheeps in total, not There are 17 sheeps in total
    
    There are 500 sheeps in total, not There are 500 sheeps in total
    
    There are no sheeps at all, you counted There are no sheeps at all
    
    Don't return a string with your answer. Though it seems that's what the sample tests want you to output, the final tests don't.
    

    With follow-up explanation from user Chrono79 :

    Test.expect(Boolean value, String error message)
    
    That's how Test.expect works
    
    countSheeps(array1) == 17
    
    Your function should return 17, not a string.
    
    Test.expect isn't encouraged to use, it's better to use Test.asserEquals because the latter shows both the actual and expected values in the error     message.
    
  • Custom User Avatar

    Your function should return a number, not that string, that's the error message.

    See the sample test, the returned value of your function is compared against 17 there, the string is only visible if you return another thing.

    Test.expect(countSheeps(array1) == 17, "There are 17 sheeps in total")
    
  • Default User Avatar

    I'm having the exact same problem (Javascript). I've read the troubleshooting section on codewars GitHub, specifically the "When I print my answer it looks exactly the same as the expected value given by assertion message, yet some/all tests fail. Why?" section, but still not come up with an answer to why my code isn't working. I'll print my code below

  • Custom User Avatar

    There are 17 sheeps in total, not There are 17 sheeps in total
    There are 500 sheeps in total, not There are 500 sheeps in total
    There are no sheeps at all, you counted There are no sheeps at all

  • Custom User Avatar

    There are 17 sheeps in total, not There are 17 sheeps in total
    There are 500 sheeps in total, not There are 500 sheeps in total
    There are no sheeps at all, you counted There are no sheeps at all