pollonz
pollonz

Reputation: 29

join method not working on array JAVASCRIPT

I created this code that I draw an array, but today I'll explain what is this code because the problem is another. I run a processing del'array "elaborazione", the problem is that when I want to remove the commas, using the join method does not work, the text remains the commas, how is it possible? What is wrong with this code?

for (i = 0; i < count; i++) 
{
   var opt = new Option();
   var elaborazione = v[i].split(";");
   elaborazione.splice(2,2);
   elaborazione.join(" ");
   alert("elaborazione => " + elaborazione);
   opt.innerHTML = elaborazione;
   select.add(opt);
}

Upvotes: 0

Views: 3173

Answers (1)

Satpal
Satpal

Reputation: 133403

.join()

The join() method joins all elements of an array into a string.

You need to save the joined string in elaborazione variable.

Use

elaborazione = elaborazione.join(" ");

Upvotes: 5

Related Questions