Last active
November 9, 2019 12:42
-
-
Save aleybe/c0a2f5e09778fa61f8c47fb2881fa997 to your computer and use it in GitHub Desktop.
Randomly Choose Saturday Night Dinner
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
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