ERROR: Uncuaght TypeError: ar.splice is not a function
/* I have written the following code in JavaScript The code opens a page where I can add a .txt-file Then the code looks trough the program to find a linebreak ('\n') When it findes this linebreak I would like the code to seperate this array and print it in the console, and then look for the next linebreak and repeat But currently I am having problems with the ERROR in the quistion name (Uncaught TypeError: ar.splice is not a function) I hope someone can help me with this and tank you for your time */ function fileReader(event) { var input = event.target; var reader = new FileReader(); reader.onload = function() { var text = reader.result; ar = reader.result.substring(0, 1377); console.log(ar); for(var i = 0; i < ar.length; i++) { console.log(ar[i]); if(ar[i] == '\n') { ar = ar.splice(1, ar.indexOf('\n')); console.log(ar); } } } reader.readAsText(input.files[0]); }