DEV Community

Discussion on: There's no "else if" in JS

Collapse
 
plainjavascript profile image
plainJavaScript • Edited

function wow(arg)
{
if (arg === "dog") return "LOVELY";
if (arg === "cat") return "CUTE";
return ("gimme an animal");
}

wow("cat");
//-> "CUTE"
// or

function anotherWow()
{
return (arg === “dog”) ? “LOVELY”:((arg === “cat”) ? “CUTE”:”gimme an animal”);
}
anotherWow(“cat”);

Collapse
 
genta profile image
Fabio Russo

Yah... but what? 😅