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.
you can also use the loose operator just in case someone mistakenly types the number as a string.
love this one
No
let
?I know it's trivial, but how is mutating the original arrays being accepted as a valid solution?. Likewise for most of the other answers here
It's slightly worse even. Integer properties come first, sorted as numbers, then other properties, in insertion order. Integers have to be non-negative (!) and no leading or trailing anything. Because property names also are, of course, strings.
So JS won't sort an array of numbers as numbers, but it will sort an array of strings as numbers, if it is
Object.keys
.It would seem better to just never ever ever rely on property name ordering. If it matters, sort it yourself explicitly, so future generations can see what ordering is actually in use.
I had the same question! I digged in and were able to find a very interesting behavior of an object numeric property - If we loop over an object that has integer properties, the properties are sorted (ascending). However, if the key are non-integers, then they are listed in the creation order. In this case, the last should be the largest integer that we want to return if there is a tie!
You can read more from this article https://javascript.info/object#ordered-like-an-object
No
const
?I like this
Hey guys, isn't it suppose to fill/complete the initial functions?
Nice hksong!
Actually, in real Pokemon, effectiveness is not always mirrored. In fact, even hitting the same type is not always guaranteed to be "not very effective".
Your solution only works for this kata. That is perfectly fine since that is the goal of code wars. What is not fine is to make false claims about things outside of code wars.
PS: If we were to follow the specifications of the kata exactly, all you would need is key value pairs of the super effective relationship. You can derive the not very effective relationships from that as well as from the fact that same types are always not very effective. Anything left over would fall under neutral. So your solution is not even optimized for this kata.
How does this resolve ties for most frequent number?
It takes the last, not the largest, which should have been caught by the tests.
why this solution is "Best Practices"?
variables firstNames and lastNames becomes global!
No var?
Actualy, in pokemon effectiveness have alway the same multiplicators, x0 x0.5 x1 x2.
So with that kind of configuration file your types don't need to know their effectiveness on all other types :
'fire' : {
supp : ['grass'],
less : ['fire', 'water']
}
It's easier to maintain.
Then you need a litle function to get effectiveness. See my solution ;p
Loading more items...