Alright, I find the code below to be quite repetitive and annoying. Any other way to refactor the code without using an array as a starting point (that is, to avoid using array[x], array[y], array[z] later on in the code as a result of starting with an array because x,y,z are completely unrelated and it makes no sense to group them for the sake of readability)
var x = ""; var y = ""; var z = ""; ... ...variables get set if(x != undefined && x != "") doSomethingHere(); if(y != undefined && y != "") doSomethingThere(); if(z != undefined && z != "") doSomethingElse(); ...
In addition to what joel said you could also do the following:
Then you could do: