Ad
  • Custom User Avatar

    I second this. It wasn't very clear

  • Custom User Avatar

    should be fixed

  • Custom User Avatar

    Extra or less spaces aren't accepted anywhere in the string. I'm not the kata's author, let's wait for him to look at your suggestion. I've added some more info at the end, that should be enough.

  • Default User Avatar

    Okay. So, not explaining that in the rules is fine. It's on me for not looking at the sample tests. Got it.

    It's just that the rules go out of their way to tell you the format can't have a trailing line, so I get it when doing so fails you.
    But the rules say nothing about formatting a new line IMMEDIATELY after the last digit. You have to discern that from elsewhere. That's why I thought it was an "issue". But, I know better now.

  • Custom User Avatar

    Sample test:

    assert.strictEqual(multiTable(5), '1 * 5 = 5\n2 * 5 = 10\n3 * 5 = 15\n4 * 5 = 20\n5 * 5 = 25\n6 * 5 = 30\n7 * 5 = 35\n8 * 5 = 40\n9 * 5 = 45\n10 * 5 = 50');
    

    Look at the expected value. There is no space after the last number of each line. The assertion compares two strings, they need to be exactly equal.

  • Default User Avatar

    When I see this as an example answer for 5,

    1 * 5 = 5
    2 * 5 = 10
    3 * 5 = 15
    4 * 5 = 20
    5 * 5 = 25
    6 * 5 = 30
    7 * 5 = 35
    8 * 5 = 40
    9 * 5 = 45
    10 * 5 = 50
    (no trailing empty line)

    and my output is this:

    1 * 5 = 5
    2 * 5 = 10
    3 * 5 = 15
    4 * 5 = 20
    5 * 5 = 25
    6 * 5 = 30
    7 * 5 = 35
    8 * 5 = 40
    9 * 5 = 45
    10 * 5 = 50
    (no trailing empty line)

    I'm going to be confused about what's "wrong" when I fail.

  • Default User Avatar

    So...what do I call it then when I'm abiding by all the rules, creating the right table, but still failing?

  • Custom User Avatar

    That's not an issue, look at the sample tests.

  • Default User Avatar

    maybe let people know the \n has to come IMMEDIATELY after the line's last digit.
    An extra/empty space between digit and \n isn't acceptable, though that's not stated in the rules.

  • Default User Avatar

    At least in JavaScript,
    having an empty space between the last digit and the \n will fail you.
    [...answer] \n
    isn't acceptable. It has to be:
    [...answer]\n

  • Default User Avatar

    Code like this is the reason I scroll through here -- code that makes me aware of new things!
    Thanks, "cheater"!

  • Default User Avatar

    Mind me asking why you prefer this to other solutions like the one-liners above?

  • Custom User Avatar

    Same here!! I was surprised when I saw this super simple line of code! I'm sure after some practice we will be able to think these solutions as well!! ✌🏻

  • Default User Avatar

    I found the instructions rather confusing, and am offering a potential revision/clarification:

    "A hero is on his way to a castle to complete his mission but the castle is surrounded by powerful dragons!
    If each dragon takes 2 bullets to be defeated, does our hero have enough ammunition?

    Return true if he has enough bullets to survive."

  • Default User Avatar

    I'm brand spanking new to coding (two weeks of self-studying) and seeing stuff like this is motivational.
    I love seeing the different ways people think and approach problems--and how SIMPLE some code can be because of it.

  • Loading more items...