chocokai
chocokai2y ago

kairu – 18-11 Dec 6

is there a better way to write an if statement like this?
js
if (
type === "image/png" ||
type === "image/svg" ||
type === "image/jpeg" ||
type === "image/gif" ||
type === "image/tiff"
) {
setWrongImageType(false);
} else {
setWrongImageType(true);
}
js
if (
type === "image/png" ||
type === "image/svg" ||
type === "image/jpeg" ||
type === "image/gif" ||
type === "image/tiff"
) {
setWrongImageType(false);
} else {
setWrongImageType(true);
}
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ScriptyChris
ScriptyChris2y ago
Array with .includes()?
[
"image/png", "image/svg", "image/jpeg", "image/gif", "image/tiff"
].includes(type)
[
"image/png", "image/svg", "image/jpeg", "image/gif", "image/tiff"
].includes(type)
reactibot
reactibot2y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1049749918698459166