Created
October 12, 2020 21:57
-
-
Save jsergiu/bf90a185141d1cd7187e7cbd4c10ac03 to your computer and use it in GitHub Desktop.
IF_ELSE
This file contains hidden or 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
// cand ai un singur caz | |
if (today == "Monday") { | |
eat_pizza(); | |
} | |
// cand ai 2 cazuri opuse | |
if (day_time == "day") { | |
stay_awake(); | |
} else { | |
sleep(); | |
} | |
// cand ai 2 cazuri care nu sunt opuse | |
if (today == "Monday") { | |
eat_pizza(); | |
} else if ((today = "Wednesday")) { | |
eat_burgers(); | |
} | |
// cand ai 2 cazuri care nu sunt opuse + o optiune cand cele 2 sunt false | |
if (today == "Monday") { | |
eat_pizza(); | |
} else if ((today = "Wednesday")) { | |
eat_burgers(); | |
} else { | |
eat_salad(); | |
} | |
// cand ai mai mult de 3 cazuri mai bine faci un switch | |
switch (day) { | |
case "Monday": | |
eat_pizza(); | |
break; | |
case "Tuesday": | |
eat_burgers(); | |
break; | |
case "Wednesday": | |
eat_fries(); | |
break; | |
default: | |
eat_salad(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment