|
|
|
|
|
by mattmanser
3994 days ago
|
|
fruit = fruit === "" ? "" : fruit || "strawberry";
Woohoo! Javascript rocks! Note that fruit = fruit == "" ? "" : fruit || "strawberry";
May or may not be bugged depending on your understanding of a bug and whether you're a marmite fan. |
|
Personally, I find that once you understand JavaScript, the beauty in what you can do, especially for input validation (which is an ugly, ugly thing) works so well in this language.