79703052

Date: 2025-07-16 07:28:25
Score: 0.5
Natty:
Report link

This variant works with an array literal, so there is no need to assign it to a variable first.

Let's say you have the literal value:

["a", "b", "c", "d", "e"]

Then, to get a random item out of that:

["a", "b", "c", "d", "e"].map(n => [Math.random(), n]).sort()[0][1];
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: meedstrom