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.
For anyone wondering, this is definitely and absolutely NOT best practice! Its not even a clever solution.
This comment is hidden because it contains spoiler information about the solution
oh nice code
i suppose the solution must be more native and contain basic language feature.))
I thought the 0 was for if the array was empty.
?=
is a lookahead assertion. It checks for the match (with any uppercase letter in this case:[A-Z]
) but doesn't include it in the match.Can somebody explain this /(?=[A-Z])/?
Great one-liner. This solution has a space complexity of O(n) because an array is allocated. In place sorting solutions can have a space completity of O(1).
That was my first solution, but it does not consider input validation according to description:
"... accepts a string containing up to 26 unique alphabetical characters."
I remember what functions exist in many languages, then do a search to find out what that particular language calls them. Most languages have a similar set of basic functions (except those languages that don't support higher-order functions cough), and that set really isn't very big. Most of what ZozoFouchtra lists exist under some alias in all languages that can handle them. For example, I may search for “js fold” (knowing
foldl
andfoldr
from Haskell), which takes me directly to MDN's page aboutArray.prototype.reduce()
. I don't use JS much, but when I do, this is my workflow..forEach()
,.every()
,.filter()
,.map()
,.reduce()
and.reduceRight()
are (useful) methods ofArray
since JavaScript 1.6.You'll find many occasions to use them in Codewars. ;)
see more @ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
How do you people come up with such answers ? do you google inbetween or you just know all the functions ?
why did you use regxp to evaluate, simple > would be more elegant!
Its grate, but this is not correct solution, instructions where rather clear you shuld accept max 26 caracters. N
"I have developed an elegant solution to this problem."
1 minute later. . .
"Oh, there was already a method for that."
Loading more items...