1

I just wanted to get all the values from the loop in a single array variable details which is declared outside the loop. But, I didn't get it wot work. How do I do this?

var details = [];
for(i=0;i<taskArray.length;i++){
    details = taskArray[i].concat("-",stateArray[i]);
}
Martin Zabel
  • 3,589
  • 3
  • 19
  • 34
Priya ranjani
  • 21
  • 1
  • 2

2 Answers2

0

just do details.push(taskArray[i])

Nagaraj S
  • 13,316
  • 6
  • 32
  • 53
Vijaykrish93
  • 150
  • 8
0

Just simple you can make use array push method, you can push items one by one, as like as below:

function cancatTaskState(taskArray,stateArray){
    var details = [];
    for(i=0;i<taskArray.length;i++){
        details.push(taskArray[i].concat("-",stateArray[i]));
    } 
    return details;
}
Kamal Raj
  • 82
  • 5
  • Thank you so much.. it works :) any idea about "org.mozilla.javascript.NativeArray@e4e213" error ? when i pass the result through web service,it shows like this. – Priya ranjani Mar 01 '16 at 13:45
  • Welcome priya...:)am not sure about java, how to pass value in web services. But this link has solution for that: http://stackoverflow.com/questions/1433382/how-to-convert-rhino-javascript-arrays-to-java-arrays – Kamal Raj Mar 01 '16 at 14:02