I have a string build form comma separated values I use split
to get each value and after that I want to show each value on a new line but what really happens is th
The for-loop is suspicious. Firstly, you do not process all items (the last one is missing, as @sarfraz pointed out). Sencondly you are returning the result (zzz
) in the for-loop body:
for (var i=0; i<=xxx; i++)
{
zzz[i] = zzz[i] + '
';
return zzz; // for-loop will stop here! resulting in ["value1
", "Value2", etc...]
}
In Javscript you can simple "join" the array:
return dates.split(',').join("
")
Since you are simply replacing strings you could use the replace
method:
return dates.replace(",", "
");