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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Now, it looks so simple to me. But my code when I tried it . . . oh boy :(
you have something like: [1, -1, 6, -6, 5]
the reduce method give the number's sum, in this case it will be 5, and this is the correct answer.
But there is a problem maybe you have something like [1, -1, 6, -6, 5, 5], in this case the sum will be 10, because we have an additional 5, to avoid that, he has removed all the duplicated numbers in the array converting it to Set type
How does it work?
is this better with 5 'return' elements instead of adding a variable 'winPlayer' and at the end adding something like 1 return with
Player ${winPlayer} won!
?I wish I could set both "best practice" and "clever" together
niice
upvote
I could not believe my eyes indeed, I dunnot about 20x but I got 8x faster 265k & 288k op vs 2.3M
Но ведь js поддерживает индексацию с конца.
arr = [3, 2, 3]
arr[-1] === arr[0] // 3 = 3
sometimes it return error or not?
Abusing JavaScript's silent treatment of sloppy data handling is not something I would call "Best Practices". If intentional though it certainly deserves the "Clever" award!
Correct, it would return [0] as expected.
mine is just O(1) and a line without if Condition.
I am a beginner myself so i may be wrong but i believe that {} is not needed if the function of the if statement is all on one line. if the if statement has no {}, then it will check for the code bellow or on the same line to the parameters of the if statement for the code corresponding to the if statement. This won't work if your if statement has more than one line under it.
Loading more items...