Using Javascript (preferably in a for loop) How can I covert an array of full names into objects so that I can split those objects into key value pairs with the keys being called "first" & "last", and the values be the full name split up into those categories?
I started out with a single string of names that were separated onto new lines...So far I have split this string into an array by using the .split("\n") method. I now have excess white space in the front of each name...not sure if that really matters or not...but I have tried .splice(" ") to try to get rid of the excess white space... but it didn't work. As you can see I need a little help. Thank you!
var nameString = document.getElementsByTagName("textarea")[0].value;
var nameArray = nameString.split("\n");
Here are the results of the split string:
[" Genevieve Harber IV",
" Dewitt Weber",
" Krystina O'Kon",
" Jeremy Adams",
" Aileen Lakin",
" Jesus Quigley",
" Shea Rempel",
" Citlalli Bernier",
" Forest Dare",
" Reina Kilback",
" Nathanael Abshire",
" Augustus Hoppe",
" Myrtis Herzog",
" Jack Senger",
" Ronny Smitham",
" Jordi Bruen",
" Leta Pfannerstill",
" Kayla Kshlerin",
" Norbert Thompson",
" Nat Lebsack"]