0

I have a text area field and I need to get all the values, then split them into array.

enter image description here

Here is my code: sample.split('\n')

When I review the logs, I've observed that there are spaces in them...

[133986 ,133979 ,133981 ]

How can I remove the spaces when I split it?

Thank you.

Saad
  • 49,729
  • 21
  • 73
  • 112
newbie
  • 14,582
  • 31
  • 104
  • 146

1 Answers1

3
var arr = sample.split('\n').map(function(element){
  return element.trim();
});
stevecass
  • 131
  • 4