Ad
  • Custom User Avatar

    wow i just saw that, of course message from test -> "Function must return a string value: expected NaN to equal '5'" refers to my handling of the empty strings. There was a conflict in my head where statement says clear integers from [0-9], but test requires a not NaN return when an empty string passes. Thank you!

  • Custom User Avatar

    wow i just saw that, of course message from test -> "Function must return a string value: expected NaN to equal '5'" refers to my handling of the empty strings there. It just was a conflict in my head where statement says clear integers from [0-9], but test requires a not NaN return when an empty string passes. Thank you!

  • Custom User Avatar

    Hi @akimochev - it's a bit hard to read your code due to all the conditions at the top, but it seems that you are checking for the case where both input strings are empty (n1 == '' and n2 == '') <- here you are using and but it should be or I think

    Also, rather than just return '0' when one of the inputs is empty string, the kata is asking you to treat the empty string as = 0, so you should return value of the other, nonempty string instead of return '0'.

    Basically it's not handling the case where only 1 of the 2 strings is empty. For example there is a test:

    n1 = "9999", n2 = "" <- correct answer is "9999"

    and looking at your checks at the start of the code, I don't believe this is handled correctly.

  • Custom User Avatar

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

  • Custom User Avatar

    Some tests in JavaScript pass in empty strings, and your solution fails on these. Empty strings should be treated as "0".
    Yes, this input sucks. But still, even though you say you check agains it, it's not done correctly.

  • Custom User Avatar

    Javascript, also tried my solution in https://www.codewars.com/kata/525f4206b73515bffb000b21 as they say its duplicated and it works there

  • Custom User Avatar

    In what language?

  • Custom User Avatar

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

  • Custom User Avatar

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