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 is smart... amazing
Nice!
It's clever for sure. But usually clever != best practice.
-12 + (-18) = -30; the target is '6 - (-12) = 18' or '6 - (-18) = 24';
There is quite good solution, but it isn't consider values such as:
So, 6 can be found by (-12 - -18) for example...
Practice. Don't listen to negative responses.
wow!
Thank you very much for your reply ;)
It's a bitwise OR operator which in this case (against 0) essentially cuts of all non integers. Here it's used as a somewhat crude and hacky way to avoid Math.floor() or parseInt().
My advise would be to be careful using it in your projects. The | 0 is easily overlooked and can leave your future you searching forever where your math doesn't add up. Math.floor() does a better job at being self-explanatory. Since the example above is very short, the | 0 doesn't hurt for the simple purpose it serves.
Also look at stanleyvarga's comment. He also makes a solid point not to use it everywhere.
What means this "|" in Javascript ?
pure gold as is
no bro :(
Your problem comes from the concept of proximity. The description says that we sould return the pair with the lowest last element's index. It means that in [10, 5, 2, 3, 7, 5] the answer is [3,7]. In [10, 5, 2, 3, 5, 7] the answer is [5,5] because the last 5 has an index lower than 7.
This comment is hidden because it contains spoiler information about the solution
If you see what I have been trying to do in 3 days, you will advice me to quit.
Loading more items...