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

190
Visualizações
Not all JavaScript If statements executing

I have a program which is not setting a String. I have a bunch of if statements which set an array with the push function, and that works, but setting the string does not. So that the String primarytype always comes up as empty at the end of all the if statements, but the array is populated. I am not sure why the array is being populated and the String is not.

const doAllOfThis = async () => {
              
              var myTitleAndDescription = response.title.toLowerCase() + " " + response.description.toLowerCase();
              myNumberOfShorts += (myTitleAndDescription.match(/shorts/g) || []).length;
                
                //response.title = response.title.toLowerCase();
                //response.description = response.description.toLowerCase();
                var myTitle = response.title.toLowerCase();
                var myDescription = response.description.toLowerCase();
                //(temp.match(/is/g) || []).length;
              if (myTitle.includes("slim") || myDescription.includes("slim") || myTitle.includes("skinny") || myDescription.includes("skinny") ){
                  myClothingKeywords.push("slim");
              }
              
              if (myTitle.includes("polo") || myDescription.includes("polo")){
                  myClothingKeywords.push("polo");
                  primarytype = "shirt";
              }
              if (myTitle.includes("flannel") || myDescription.includes("flannel")){
                  myClothingKeywords.push("flannel");
              }
              if (myTitle.includes("t-shirt") || myDescription.includes("t-shirt")
                ||myTitle.includes("tshirt") || myDescription.includes("tshirt")){
                  myClothingKeywords.push("t-shirt");
                  primarytype = "shirt";
              }
              if (myTitle.includes("jacket") || myDescription.includes("jacket")){
                primarytype = "jacket";
                  myClothingKeywords.push("jacket");
                  
              }
              if (myTitle.includes("bomber") || myDescription.includes("bomber")){
                  myClothingKeywords.push("bomber");
              }
              if (myTitle.includes("sweatshirt") || myDescription.includes("sweatshirt")){
                  myClothingKeywords.push("sweatshirt");
              }
              if (myTitle.includes("pants") || myDescription.includes("pants")){
                primarytype = "pants";
                  myClothingKeywords.push("pants");
                  
              }
             
            }
            const doBigOne = async () => {
              promises.push(await doAllOfThis());
            }
}
}
        promises.push(await doBigOne());
about 4 years ago · Juan Pablo Isaza
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