I have the following function:
function getId(a){
var aL = a.length;
for(i = 0; i < aL; i++ ){
return a[i][2].split(\":\", 1)[0];
}
You gotta cache the string and return later:
function getId(a){
var aL = a.length;
var output = '';
for(var i = 0; i < aL; i++ ){
output += a[i][2].split(":", 1)[0];
}
return output;
}
You can do that with yield in newer versions of js, but that's out of question. Here's what you can do:
function getId(a){
var aL = a.length;
var values = [];
for(i = 0; i < aL; i++ ){
values.push(a[i][2].split(":", 1)[0]);
}
return values.join('');
}
So final code will look like...
function getId(a){
var result = '';
var aL = a.length;
for(i = 0; i < aL; i++ ){
result += a[i][2].split(":", 1)[0];
}
return result;
}