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.
Hello,I'd like this solution, please let me know how it code exactly works?
because of best practices
I think thats because of js optimization. I've also tried with .every() but I found that if I don't use an index in condition function - it is NOT called twice for [25,25], js "predicts" that if first call returned true, there no need for second check for the same value. Of course workaround with using index worked but looked ugly. So I just used .reduce() instead.
Now I guess that 'bind' is also a workaround
why do you need to bind?
"If such an element is found, the every method immediately returns false. "
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
I don't get why the name of the clerk needs to be kept as a variable.
I think instead it should be...
I also don't get why there are 3 (edit: 2.5???) functions instead of putting all of that in 1 function.
Wow! Your decision is great! Thanks for it!
Agree with you, no offence but this looks like fancy overkill
Nice syntax solution. But why you are using every() function. Isnt it more efficient to stop after the first matched negative value ?
Thanks for your explanation a lot.
So, what you mean is that 'this' of vasya's method (if passed to the .every() just as vasya.sell) will be bound to the personInLine which, in return, will not have 'money' object inside causing an error?
If so, then I got it. But it took me some time.
Because
vasya.sell
is just the function (Function Object
), unexecuted, unbound.If you want to execute that function with
this
bound tovasya
, you have tobind
it and then later execute it, or execute the function asvasya.sell($something)
in one expression.There is a difference between
.every( vasya.sell )
and.every( personInLine => vasya.sell(personInLine) )
. Maybe there need not have been a difference, but there is. There's something to be said for ( and against ) both possibilities.Isn't it a bit overcomplicated for the task? Why wrapping the solution into an object with functions is so upvoted as a best practice, where just a switch seems to be enough?
it's because there never be a situation when the clerk should give change from 100; there always less than 100. f.e 100-25 = 75
This comment is hidden because it contains spoiler information about the solution
Impressive!
Loading more items...