How would I populate an array from text in a <textarea> input?
My end goal is to take a list of names and then insert it into an array to perform some operations. The names would be separated by lines, like this:
bob
tim
sally
and then added to the array. To be honest, I don't know where to start other than adding the <textarea> and creating a blank array. I was reading other posts, but they were in jQuery or some other language that I don't know yet. My understanding is that I have to split the content somehow?
var array = textareaElement.value.split('\n');mapandtrim. If you want to remove empty strings usefilter:var array = textareaElement.value.split('\n').map(e => e.trim()).filter(e => e);.