Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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, notO(1)
.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.
Would that not include 5? I thought it was inclusive if you did it that way.
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. :)
your code is clear and readable, but one thing, avoid using Var.
Thank you.
This is a damn Readable code. Awesome..
besides not returning directly the expression i believe this can be categorized as best practices.
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
you are missing some white spaces
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?
Not really ideal algorithm if distributing 100,000 candies to a couple of children...