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

    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.

  • Custom User Avatar

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

  • 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.

  • Custom User Avatar

    You are misusing the Conditional (ternary) operator (see examples following the link).

  • Custom User Avatar

    Please use a spoiler flag next time you give elements of a solution.

    You must return a value, your function currently returns nothing. There's no point in calling the function inside your code as you do at the end.

    See if this can help you: Troubleshooting Your Solution.

    No one is here to teach you programming, this is a very basic kata you can find the whole JavaScript documentation online.

  • Custom User Avatar

    Hi. Please use spoiler flag when divulgating elements of solution. A problem with your code is not a kata issue, please mark it as a question and not an issue next time. You need to use the provided name argument, what you do always returns the same result. Also you don't need to call the function inside your code, the tests do it themselves.

  • Custom User Avatar

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