What’s the easiest way to retrieve 2 arrays from 1 txt file with javascript?
so
Steve~kid
Bob~adult
Chris~kid
becomes
Names array
Steve, Bob, Chris
&
Type array
kid, adult, kid
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By default you can’t access system files from the browser, although there are some options such as the fileReader API in some modern browsers and of course, Node JS, but that’s for server stuff.
Note: If the files are on your server then you can do an AJAX request.
But assuming you find out how to get the contents of the file into a string variable, you can create the arrays like: