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());