Answers for "switch case with object"

0

javascript object instead of switch

const dogSwitch = (breed) => ({
  "border": "Border Collies are good boys and girls.",
  "pitbull": "Pit Bulls are good boys and girls.",
  "german": "German Shepherds are good boys and girls."
})[breed]
dogSwitch("border") // "Border Collies are good boys and girls."
Posted by: Guest on April-26-2021
0

typescript inline switch

{(() => {
    switch (header) {
                        case "Name":  return entry.name;
                        case "Type": return entry.type;
                        default: return entry.name;
                    }
})()}
Posted by: Guest on December-15-2020

Code answers related to "switch case with object"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language