dotfiles/data/home/.local/bin/pick_random
2024-06-18 03:14:30 +02:00

13 lines
273 B
TypeScript
Executable file

#!/usr/bin/env -S deno run
const { args } = Deno;
const { random, floor } = Math;
function pick_rand(options) {
const fac = options.length * random();
const index = floor(fac);
return options[index];
}
let chosen = pick_rand(args);
console.log(`chose '${chosen}'.`);