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.
Oh, never mind. I see that there is an initial value of an empty string supplied. Very cool!
Is this true? I don't see how this bit handles the first element in a long list. Since reduce() is not given an initial value, doesn't it start with an index value of 1? From MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce): The index of the current element being processed in the array. Starts from index 0 if an initialValue is provided. Otherwise, it starts from index 1.
With ES6 the last line can be changed to
return Math.min(...numCakes);
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Hardcoded the answers to tests XD
This comment is hidden because it contains spoiler information about the solution
yes but it doesn't work with very large numbers
ex. seven(30000000000) = [-1294967296, 1].
Math.trunc() is better practice.
Read more here: https://stackoverflow.com/questions/7487977/using-bitwise-or-0-to-floor-a-number