Jump to content

Pick random element: Difference between revisions

m (Move FutureBasic entry to correct location)
(→‎Joy: add)
Line 914:
<syntaxhighlight lang="javascript">var array = [1,2,3];
return array[Math.floor(Math.random() * array.length)];</syntaxhighlight>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">DEFINE pick_random == dup size rand swap rem at.
 
(* initialize random number generator *)
time 89 * clock + srand
 
["zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve"]
pick_random.</syntaxhighlight>
 
=={{header|jq}}==
559

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.