Rewriting the title

I think, this is the fix:

function run() {

	for (const listing of selectedListings) {
		
		var thisBrand = "";
		var thisSize = "";
		var thisColour = "";
		var thisPattern = "";
		var thisFeatures = "";
		var thisType = "";

		if (!listing.attributes["Brand"] || listing.attributes["Brand"]=="") {
			consoleLog("NO BRAND");
		} else {
			thisBrand = listing.attributes["Brand"] + " ";
		}

		if (!listing.attributes["Size"] || listing.attributes["Size"]=="") {
			consoleLog("NO SIZE");
		} else {
			thisSize = "Size" + " " + listing.attributes["Size"] + " ";
		}

		if (!listing.attributes["Colour"] || listing.attributes["Colour"]=="") {
			consoleLog("NO COLOUR");
		} else {
			thisColour = listing.attributes["Colour"] + " ";
		}

		if (!listing.attributes["Pattern"] || listing.attributes["Pattern"]=="") {
			consoleLog("NO PATTERN");
		} else {
			thisPattern = listing.attributes["Pattern"] + " ";
		}

		if (!listing.attributes["Features"] || listing.attributes["Features"]=="") {
			consoleLog("NO FEATURES");
		} else {
			thisFeatures = listing.attributes["Features"] + " ";
		}

		if (!listing.attributes["Type"] || listing.attributes["Type"]=="") {
			consoleLog("NO TYPE");
		} else {
			thisType = listing.attributes["Type"] + " ";
		}

		listing.title = "Text" + " " + thisBrand + thisSize + thisColour + thisPattern + thisFeatures + thisType + "Text";

	}
}
1 Like