Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Last active February 13, 2023 23:55
Show Gist options
  • Save ernestofreyreg/8001d9fe377a4dda03024f97fa7b3efc to your computer and use it in GitHub Desktop.
Save ernestofreyreg/8001d9fe377a4dda03024f97fa7b3efc to your computer and use it in GitHub Desktop.
let who = ['The dog','My grandma','His turtle','My bird'];
let action = ['ate','peed','crushed','broke'];
let what = ['my homework', 'the keys', 'the car'];
let when = ['before the class','right on time','when I finished','during my lunch','while I was praying', "yesterday"];
function randomIndex (arr) {
return Math.floor(Math.random() * arr.length);
}
function randomValue (arr) {
const rIndex = randomIndex(arr);
return arr[rIndex];
}
function randomExcuse (arrayWho, arrayAction, arrayWhat, arrayWhen) {
return randomValue(arrayWho) + ' ' + randomValue(arrayAction) + ' '
+ randomValue(arrayWhat) + ' ' + randomValue(arrayWhen);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment