Last active
February 13, 2023 23:55
-
-
Save ernestofreyreg/8001d9fe377a4dda03024f97fa7b3efc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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