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.
🙏
Wow .... so easy with your method ! Nice job !
Love your regex logic
Thank you, this is a good point.
Great job. I would recommend making the empty/undefined element in the
keys
array explicity undefined for readability.const keys = [' ',undefined,'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz'];
Can be difficult to see the empty element.
Thank you, your advices has a sense.
Foreach
here would be perfect choice.Reduce
is also an option, but as with amap
case, there will no further chaining afterreduce
, so it would be not so much neccessery.Solution with
map
+join
is also a good case, so we can get rid ofresult
variable. But in this case we additionally need to handle empty string scenario:return ......map().join('') || '';
Why
map
if you do not use the resulting array?Semantically, it is
forEach
then.Or better use
reduce
not to manipulate extra variable outside method.Or much better map the matched array and use
join
to get the final string...You can use an array instead of number-indexed object
marray.length/2 is repeated 3 times, maybe it would be better to add variable.
The garden should have the exact amount of plants in the end. Not more.
Imho this kata should be greater then 6 kyu.
If the string does not match regexp return null
null || [] returns [];
That's what I thought too but the result has to be right, if you just wait to overtake it can't work.
It might be better if you move compare cur and max to else block. Then this compare goes only when chain breaks. Now compare goes for each vowel.
If you don't fill, the array is considered empty for .map, so .map returns an empty array. You can fill it anything, even undefined, but you have to do it or otherwise map doesn't do anything.
Loading more items...