Click here to Skip to main content
15,070,974 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a text file which contains a list of words. I would like to open it, read it line by line and save its content as a string list, so that each word becomes an elemetn of thes string list. The I need to shuffle it to randomise the order. Could someone please explain me how to do this with JavaScript? I am very lost and would be very grateful for any help.

What I've tried (see below) opens the file on the server, but I want is a function that opens, reads the file and makes a list in the code. I hope this makes sense.

What I have tried:

    <title>Read Text File</title> 
    <input type="file" name="inputfile"
    <pre id="output">

.addEventListener('change', function() {

var fr=new FileReader();

Updated 16-May-21 10:38am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900