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 that I get each value on a new line except of the last two which are shown together on a same line. Just to make it clear:
value1
,value2
,value3
,value4,value5
Here is the function which I'm using:
_checkDates: function(dates) {
if (dates != null)
{
var zzz = dates.split(',');
var xxx = zzz.length;
console.log(xxx);
for (var i=0; i<=xxx; i++)
{
zzz[i] = zzz[i] + '<br />';
return zzz;
}
}
return dates;
}
Just to be clear this is written in ExtJS 4, I'm almost sure that in this case the problem is pure JavaScript and is not related with ExtJS 4 but anyways, maybe I'm wrong.
So any ideas why does it happen and how I could make that last element to get on a new line as well?
<
and<=
even with==
it didn't work. I don't know the reason why the<br />
tag is not assigned, in fact that is why I post the question. The answer of Stefan below solve my current problem but I would be grateful if someone tell me where is the mistake in my script and how to modify it in order to work properly. – Easiness