Cool point. In cases like this, I often forgo the else altogether because of the return statements.
if(arg === "dog") return "LOVELY";
if(arg === "cat") return "CUTE";
return "gimme an animal";
Still, your point about understanding the why behind what we write is an important one. Thanks for sharing.
A function with only ifs that return is just the missing-from-JS pattern matching+guards syntax.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.