I am writing a function that takes and array of objects and delimiter as
arguments. It then is supposed to take each array element's property and
add it to a string variable. So I should get something like:
textbox|txt_name|txt_size||radio|rad_name|rad_value||...
as output. However, when I view the resulting string, I get all undefined
for values.
Here is the function I'm using:
function JoinArrayOfObjects(oArray, sDelimiter) {
var sString="", sProp, obj;
for (obj in oArray) {
for (sProp in oArray[obj]) {
sString = sString + oArray[obj].sProp + sDelimiter;
}
sString = sString + sDelimiter;
}
return sString.substr(0,sString.length-2);
}
Can anyone figure out, please, what I am doing wrong? I think it has to
be a problem with the innermost statement, but I don't see what could
possibly be wrong with it.
Chris