Skip to content

Instantly share code, notes, and snippets.

@msarit
Last active July 26, 2019 16:42
Show Gist options
  • Select an option

  • Save msarit/ce15fb6c8cb980bae6e190f4c48f56cf to your computer and use it in GitHub Desktop.

Select an option

Save msarit/ce15fb6c8cb980bae6e190f4c48f56cf to your computer and use it in GitHub Desktop.
example-code.js
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function setAction(actions){
let action = actions[getRandomInt(6)];
if (action === 'gives away') { setAction(actions) }
else { return action }
}
function setItem(items){
const item = items[Math.floor(Math.random() * items.length)];
return item;
}
function setLocation(locations){
const location = locations[Math.floor(Math.random() * locations.length)];
return location;
}
function tongueTwister(actions, items, locations){
const thisAction = setAction(actions);
const thisItem = setItem(items);
const thisLocation = setLocation(locations);
return `She ${thisAction} ${thisItem} by the ${thisLocation}; the ${thisItem} she ${thisAction} are ${thisLocation} ${thisItem}`;
}
export default tongueTwister;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment