Skip to content

Instantly share code, notes, and snippets.

@aleybe
Last active November 9, 2019 12:42
Show Gist options
  • Save aleybe/c0a2f5e09778fa61f8c47fb2881fa997 to your computer and use it in GitHub Desktop.
Save aleybe/c0a2f5e09778fa61f8c47fb2881fa997 to your computer and use it in GitHub Desktop.
Randomly Choose Saturday Night Dinner
function chooseMyUberDinner() {
var listofplaces = $('.eb').children
var listofopportunities = []
for (var place in listofplaces) {
var currentplace = listofplaces[place]
if (currentplace.children === undefined) {
continue;
}
var storeText = currentplace.children[0].text
// check validity
if (storeText === undefined
|| storeText.startsWith("Currently unavailable")
|| storeText.startsWith("Opens on Sunday")) {
continue;
}
listofopportunities.push(storeText)
}
// We now have a list to choose from, randomly choose one
// Choosing
var choice = Math.floor(listofopportunities.length * Math.random())
return(listofopportunities[choice])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment