Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 13365626?s=100
  • 11658002?s=100

    don't be discouraged dude! Just keep learning. It is a bottomless pit of things to learn :) just keep at it. The most important part is that you are SOLVING the problems!

  • 35849163?s=100

    I recommend the site https://regex101.com to build/test/learn RegEx.

  • 3655666?s=100

    Way to solve kata!

    Keep in mind, the goal is to solve the issue, not resolve it in the least amount of lines. If you successfully finished the challenge in 6 lines, consider it a win!

    Use others' solutions to get a better understanding of different ways of doing it. If you don't understand their solution, use Google to research the methods they use. The more you learn, the more efficient you'll be, and soon these one-liners will come naturally to you.

    Also remember: shorter is not always better. This particular solution is good, but others may sacrifice readability for brevity (which is also why codewars has separate categories for "Best Practices" and "Clever"). Since you're just starting to learn, try to focus on solving the challenges and learning from others over having the best, most pristine solution the first time.

  • Profile pic

    This looks great, but is way over my head. Can someone break down to me what is going on? For example, how calling "four(times(five))" will even be executed there?

  • Profile pic

    I adjusted the reference solution so that it doesn't modify the existing hash.

    It doesn't test for not doing this, but almost no kata does that, though it could be a BP for languages like Ruby which have bang annotation for mutating functions?

  • 8613845?s=100

    I did like this too ! Kinda proud of me :)

  • 18171520?s=100

    .. takes a .. hash .. and returns that hash ..

    ( my emphasis )

    Maybe the function should have a different name ( sounds like a very useful convention BTW! ), but that's not the original issue, and I'm not sure it qualifies as an issue ( it might. I don't know how strict that convention is generally adhered to ).

    The description is very clear that the hash should be modified in place.

    Should this be closed, or not?

  • 14909989?s=100

    you can declare a regex outside of your function if you use ES6 so you only compile the regex once, instead of on each call.

    This is not a known JS practice at all (as a rule of thumb, if most reputable sources doesn't suggest a practice, it's either not a practice or it's negligible). Even if this is true in every other language it does not make such better practice in this language. It's a invalid suggestion.

    the readability is pretty terrible

    If you can't read simple regex like this, I'd say the problem is at somewhere else than the regex...

  • 14909989?s=100

    That fails for 5 digits numbers.

  • Profile pic

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

  • Profile pic

    Might want to look up what test does.

  • Profile pic

    Nah. Modern JS engines like V8 are smart enough to cache certain things on repeated calls. The only thing lacking would be comments, but a one liner like this doesn't really need comments. You can also place the const inside the function. Again, modern engines are smart enough to not initialize it on every call. Also, the description makes no mention of repeated calls within a short period of time. For a real pin validation, you only need to validate pins until the user gets it right or is locked out. The overhead for initializing such a short regex is nonexistent. And a user is probably not executing thousands of calls every millisecond.

    This is obviously not meant for production, so there is no reason to nitpick. But since you already started, in a real production environment, defining a regex in the global scope would be terrible practice. You are also not following const NAMING_CONVENTIONS. Could keep going, but you should get the point by now.

  • 23709795?s=100

    Additionally, example tests for JS are missing, there's not a single one.

  • Profile pic
  • Loading more items...