Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda