-
-
Save alexandrutapirdea/d25c3e3bc06c48b1d424587a0730109c to your computer and use it in GitHub Desktop.
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
// 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