I have a textbox in reactjs. I want to slice its contents by new lines, outputting an array.
For example, if the textbox has
foo
bar
foobar
I want to get
['foo', 'bar', 'foobar']
Any ways I can do this?
>Solution :
\n means new line, I suggest trimming the text before splitting.
string.trim().split('\n')