objecthub-io / ObjectHub

ObjectHub is an open repository for software objects and a development platform.
2 stars 1 forks source link

cb function issue in iterating through arrays #225

Closed panditthecoder closed 7 years ago

panditthecoder commented 7 years ago

cb function has an issue iterating through arrays where the elements are named......

example which works :

JS code


`var namerecd = [];
for (var i=0;i<input.Names.length;i++) {
    namerecd[i] = input.Names[i];
}
cb(null, {message: "this is the list " + namerecd });`

Output /Result


{ "message": "this is the list Joe,Peter,Pan" }

example which does not work

JS Code


var namerecd = [];
for (var i=0;i<input.Names.length;i++) {
    // the variable i has been replaced with the identifier "name" in the next line
    namerecd["name"] = input.Names[i];
}
cb(null, {message: "this is the list " + namerecd });

Output/Result


{ "message": "this is the list " }

panditthecoder commented 7 years ago

bad example. let me put in a better one

objecthub-io commented 7 years ago

Ok, thank you!