0
Multiple if statements (an array)?
How can I get the following function to return multiple color types (not just red, but also orange, yellow, etc.)? function isRainbowColor(color){ if (color === "red"){ return true; }else{ return false; } } console.log(isRainbowColor("red")); //This works but only for one color at a time. Any suggestions?
2 Antworten
+ 1
if (['red','orange','yellow',...].includes(color))
will do the trick ;)