Doing some simple substring removal and getting different results from the block than in JS Bin.
let renderName = "MX_Topo-Chico-Agua_Mineral-Water_600ml_PET_6x";
let secondaryQuantity = "6x";
// scripting block generates an UNEXPECTED output: "MXTopo-Chico-Agua_Mineral-Water_600ml_PET"
output.text( removeSubString(renderName,secondaryQuantity) );
// JS Bin, however, outputs as EXPECTED: "MX_Topo-Chico-Agua_Mineral-Water_600ml_PET_"
// console.log( removeSubString(renderName,secondaryQuantity) );
function removeSubString(str,substr) {
return str.replace(substr,"");
}
Oddly, making use of a character (rather than “”) yields proper results.
renderName.replace(secondaryQuantity,"1")
=> "MX_Topo-Chico-Agua_Mineral-Water_600ml_PET_1"