Hello! I am working on an attribute rule that will concatenate 6 fields that make up a street address to create a full address. The problem is that 2 of the fields are not always populated with a value. They will either be null or empty.
In the image below, you can see my 6 fields (ST_NUM, DIRPRE, FEANME, FEATYP, DIRSUF and Unit (LV_APT)

If I do a simple concatenate of those fields, the result will leave spaces at the end of the full address. I know this is because of there not always being a value in DIRSUF or LV_APT.
I have been working on the below code, but I know I am missing some parts. Any ideas or anyone know a better way?
// List the fields to combine
var parts = [$feature.ST_NUM, $feature.DIRPRE, $feature.FEANME, $feature.FEATYP, $feature.DIRSUF, $feature.LV_APT];
// Loop through the address parts, if not null or empty add them to a new array
var filteredparts = [];
for (var i in parts) {
var value = parts[i];
if (IsEmpty(value)) continue;
filteredparts[Count(filteredparts)] = value
}
// Concatenate with a space
return Concatenate(filteredparts, " ");