0

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);
}
1
  • join method doesn't change the variable but "returns" the joined string. assign the returned value to elaborazione. Commented Oct 13, 2014 at 12:28

1 Answer 1

5

.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(" ");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.