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);
}
UU
Unknown User499d ago
S
ScriptyChris499d 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)
UU
Unknown User498d ago