Ad
  • Custom User Avatar

    I just wanted to do this without modulo. Lmao

  • Custom User Avatar

    I don't think using regex on a kata called "Regex validate [...]" is missing the point. This regex is also O(n) with respect to the input length, not O(1).

  • Custom User Avatar

    All of these solutions use REGEX. I mean.. it works, and is definitely the best practice because of O(1) complexity but it's also kind of missing the point imo.

  • Custom User Avatar

    Would that not include 5? I thought it was inclusive if you did it that way.

  • Custom User Avatar

    Thanks. Though I haven't updated this kata I feel I feel should mention that I created it before const and let were a part of JS. :)

  • Default User Avatar

    your code is clear and readable, but one thing, avoid using Var.

    Thank you.

  • Default User Avatar

    This is a damn Readable code. Awesome..

  • Custom User Avatar

    besides not returning directly the expression i believe this can be categorized as best practices.

  • Custom User Avatar

    Regexp in fact is not difficult, at least on this excercise but ist easy to read tho, if you get like those regexp like ^(-.%[a-z+]{4}$-()) and stuff its super complicated, at least for me that i am not a genius considering myself as an average programmer trying who tries to improve lol

    In fact for this kata before that i was searching on reg101, regxr, wiki, document, and more to do an exact range of numbers and i cant, then someone teach me about the ^ and $ thats are neede to format explicit a numbers that will be accepted

    My opinion

    ps. sorry my english

  • Default User Avatar

    you are missing some white spaces

  • Default User Avatar

    Apart from the last bit, when you could return directly (isCorrectLength && hasOnlyNumbers), i found that this is the clearest solution. Easy to read, not over-engineered. I think that this community is a bit obsessed about writing super-concise one-liner code: this works and it's super-readable, some developers prefer to write some additional lines of code instead of sacrificing clarity and readability... what's the problem?

  • Default User Avatar

    I think everyone needs to chill on this one lol

  • Custom User Avatar

    Sure sure, if you mean "any skill level" = "typical Java/C programmer". Yes, regex is incredibly difficult to use in Java and C so nobody uses them there, and hence it's not even taught in most CS curriculum. But this is JS. JS has easy to use regex, and it's a very commonly use part of the language. (The same goes to Python.)

    You're submitting a JS solution. JS is not Java.

    If you're writing code in a language in the style of a completely different language
    , nobody in the world would call your code good. No matter how you believe otherwise.

    Conflating "readable and maintainable" to "code monkey tier code" is the real strawman here: again, you're submitting a JS solution, so if you're using pure Java practices, you might as well write a Java solution instead.

  • Custom User Avatar

    Alright - I'd be willing to bet $100 that if you put my solution in front of a developer of any experience level, 99% of the time they would instantly be able to understand what is going on. The same cannot be said for the most popular solution for this kata without having to learn what is essentially another language. Your argument is essentially "to understand this solution, you need to understand this solution", which is even more moot than yours... I'm giggling to myself a little because you're trying to call me out for not knowing a language I have already admitted to not having learnt at the time. You could write the solution in base64 for god's sake, but if you didn't know what base64 was or how to understand/read it, you're not going to have a solution that is understandable by the majority.

    tl;dr Nice strawman argument, my solution is understood at any skill level.

  • Custom User Avatar

    ...? It's not even a complicated regex (like the one in the top solution). I also argued at that solution, but if regex like that is "hard to grok", "have to untangle the regex in your head" and "causes too much mental load"... then the problem is not about regex anymore, it's about the person reading the code. And the whole point would then become moot: essentially you're asking someone who can't read English to comprehend English.

  • Loading more items...