Skip to content

Instantly share code, notes, and snippets.

@jsergiu
Created October 12, 2020 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsergiu/bf90a185141d1cd7187e7cbd4c10ac03 to your computer and use it in GitHub Desktop.
Save jsergiu/bf90a185141d1cd7187e7cbd4c10ac03 to your computer and use it in GitHub Desktop.
IF_ELSE
// 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