Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
multiple check if statement

hello so what I am trying to do is to check if selectedItem.status is any of these numbers I don't want react do move on into the next blocks.

I have tried to do this another way like for example

 if(selectedItem.status !== ["16", "0", "12", "9", "11", "13", "17", "22"].indexOf(selectedItem.status))

but it didn't work either

    if (
      selectedItem.status !== "16" ||
      "0" || 
      "12" ||
      "9" ||
      "11" ||
      "13" ||
      "17" ||
      "22"
    ) {
      if (!showErrorPage) {
        setShowErrorPage(true);
      }
      if (selectedFile && selectedItem["id"] === selectedFile["id"]) {
        errorCloseHandler();
        setClickedStatusId(0);
        return;
      }
      setSelectedFile(selectedItem);
      setClickedStatusId(selectedItem.id);

      if (!showErrorPage) {
        setHeadCells(
          originalHeaderColumns.map((h) => {
            h.hidden =
              h.id !== "userLogin" && h.id !== "fileName" && h.id !== "status";
            return h;
          })
        );
      } else {
        setHeadCells(originalHeaderColumns);
      }
    } else {
      return;
    }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use the array includes method. It will also check for element if it exists in the array and based on that you can apply your logic.

if(["16", "0", "12", "9", "11", "13", "17", "22"].includes(selectedItem.status)){
 // your code here.
}

This should work here.

about 4 years ago · Juan Pablo Isaza Relatório

0

This should work:

if (["16", "0", "22",...].includes(selectedItem.status)) {
  ...
}

So should:

 if (
      selectedItem.status !== "16" ||
      selectedItem.status !== "0" ||
      selectedItem.status !== "12" ||
      ...
 )
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda