Looking for a way to load an array from a text file in JavaScript? Here's what I have:
var linePoints = [[0, 3], [4, 8], [8, 5], [12, 13]];
But rather than defining it in the code, I'd like to read it from a text file. The file looks like this:
input.txt:
0 3
4 8
8 5
12 13
I came across this post on Stack Overflow, which discusses something similar but for a 1D array. I'm wondering if there's a special function that can be used for a 2D array. In Java, I would read each line and then split it, but as a newcomer to JavaScript, I'm not sure how to approach this task.