Skip to content

Instantly share code, notes, and snippets.

@alexandrutapirdea
Last active April 29, 2021 15:49
Show Gist options
  • Save alexandrutapirdea/d25c3e3bc06c48b1d424587a0730109c to your computer and use it in GitHub Desktop.
Save alexandrutapirdea/d25c3e3bc06c48b1d424587a0730109c to your computer and use it in GitHub Desktop.
// The son will climb the tree and check the weather
const sonChecksWeather = () => {
const possibleOutcome = ["Sunny","Rainy","Unexpected error"]
setTimeout(()=>{
const randomNumber = Math.floor(Math.random()*2);
const result = possibleOutcome[randomNumber];
console.log("Son: The weather is ", result)
// the father will decide
fatherWillDecide(result)
},2000)
}
// Based on the response, the father will make a decision
const fatherWillDecide = (weather) =>{
console.log("Fahter says:")
if(weather === "Sunny"){
console.log("We will go boating")
}
else if(weather === "Rainy") {
console.log("We will stay home and play boardgames")
}
else {
console.log("I don't want to risk if we don't know. Let's watch TV")
}
}
sonChecksWeather();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment