Skip to content

Instantly share code, notes, and snippets.

@BrianKendalBucek
Forked from jawiki/lunch
Created July 12, 2022 19:34
Show Gist options
  • Save BrianKendalBucek/cc5995dbbc68dfc317bb032bf22c3011 to your computer and use it in GitHub Desktop.
Save BrianKendalBucek/cc5995dbbc68dfc317bb032bf22c3011 to your computer and use it in GitHub Desktop.
What should I do for Lunch?
/*
* Modify the contents of the function below, such that:
*
* If we're not hungry, we want to tell ourselves to get back to work.
* Otherwise, we want to pick something up and eat it in the lab when
* we've got less than 20 minutes or to try a place nearby if we've
* got between 20 and 30 minutes. If we have any more time than that,
* we want to remind ourselves that we're in a bootcamp and that we
* should reconsider how much time we actually have to spare.
*
* hungry is a Boolean, representing if you're hungry or not.
* availableTime is a Number representing the time you have for lunch,
* in minutes.
*/
const whatToDoForLunch = function(hungry, availableTime) {
console.log("I don't know what to do!");
if (hungry = false)
console.log("wait until you're hungry.")
if else (hungry = true && availabletime <= 20)
console.log("pick up a snack.")
if else (hungry = true && availabletime >= 20 && availableTime <= 30)
console.log("cook a tasty meal.")
if else (hungry = true && availabletime >= 30)
console.log("you should probably reconsider.")
}
/*
* This is some test runner code that's simply calling our whatToDoForLunch function
* defined above to verify we're making the right decisions. Do not modify it!
*/
console.log("I'm hungry and I have 20 minutes for lunch.");
whatToDoForLunch(true, 20);
console.log("---");
console.log("I'm hungry and I have 50 minutes for lunch.");
whatToDoForLunch(true, 50);
console.log("---");
console.log("I'm not hungry and I have 30 minutes for lunch.");
whatToDoForLunch(false, 30);
console.log("---");
console.log("I'm hungry and I have 15 minutes for lunch.");
whatToDoForLunch(true, 15);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment