Ad
  • Custom User Avatar
  • Default User Avatar

    I know you asked this question a long time ago, but I think it is because trim() removes leading and trailing white spaces. The Kata asks you to remove all spaces, including the ones in between strings of characters.

  • Custom User Avatar

    Please use spoiler flag next time.

  • Default User Avatar

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

  • Default User Avatar

    Looks like you're from Kazakhstan as well as me) But that's not about the question. I think you've already got the right answer, but a strong wish to help you out makes me to keep on). I think the problem is that you have separated firstname and lastname. I am a newbie as well, but as I understood test checks your code via string that contains both name and surname. By the way, the kata contains small tip: "This kata strictly takes two words with one space in between them.". So you've got to use this tip, because finding space can show the way to the first letter of surname.

  • Custom User Avatar

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

  • Custom User Avatar

    Your post contained the whole solution, that's why it was a spoiler. Posts here are visible in the homepage if you don't flag them.

  • Default User Avatar

    Ok, sorry for spoiler. I was think this issimple question, not spoiler.

    Thank you for the answer!

  • Custom User Avatar

    Please use spoiler flag next time, and yes it's ES6 syntax.

  • Default User Avatar

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

  • Default User Avatar

    you need to return the value, not print

  • Default User Avatar

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

  • Custom User Avatar

    Please say which language you're using (I can't even know if your code is syntactally correct). You do not modify the string by printing it, so it does not work (you always return the original string), and you don't have to call the function inside your code as you do at the end, tests do that by themselves.

  • Custom User Avatar

    No problem, welcome :) But you have to practice and learn by yourself, for many 8kyus katas in JS you'll find easily the answers online (and for this one in particular).

  • Custom User Avatar

    Yeah, as akar-0 says, you are using conditional (ternary) operator wrong.

    When using conditional (ternary) operator you need to make it as small as possible and not too complicated. It is a shortcut to a normal if starment, not a replacement.

    Basically you cannot call return inside the conditional (ternary) operator, and that is all your issue is. Istead try these:

    console.log(myBool ? 1 : 0)
    
    return myBool ? 1 : 0
    

    With conditional (ternary) operator you normally replace the value in a call, not the call itself.

  • Loading more items...