['red', 'blue', 'yellow'].find((d, i) => i === Math.round(Math.random() * 2))
`Math.round(Math.random() * 2)` might produce the following sequence: 2, 2, 0. The find callback is called with 0, 1, 2, so it returns nothing.
Maybe they were going for:
['red', 'blue', 'yellow'][Math.round(Math.random() * 2)]
['red', 'blue', 'yellow', null][Math.round(Math.random() * 3)]
`|0` is a good trick, I'll have to remember that.
I wouldn't recommend using this unless you're trying to shove milliseconds in this type of operations.
`Math.round(Math.random() * 2)` might produce the following sequence: 2, 2, 0. The find callback is called with 0, 1, 2, so it returns nothing.
Maybe they were going for:
If they intended for `undefined` or `null` to be a valid result, then it would be better to write: Haha, I submitted a PR: https://github.com/tannerlinsley/react-move/pull/1