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
  • 41,639
  • 19
  • 63
  • 109
newbie
  • 14,136
  • 30
  • 101
  • 141

1 Answers1

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