I have two databases that I've read from an Excel file, and I converted it to JSON. (my project is in JavaScript)
The first database is a planed track that the pilot should follow, and the second database is the actual track.
I need to calculate the average distance between the tracks. The problem is that the tracks don't have the same amount of points on them and so I don't know what distance should I calculate.
I printed the databases with chart.js and they are looking like this:

You could use map() to calculat the differences, reduce() to get the total and then divide by the length.
const distancesA = [17, 54, 87, 101, 120];
const distancesB = [12, 57, 82, 100, 125];
const averageDistance = distancesA.map((d, i) => d - distancesB[i]).reduce((acc, val) => acc + val, 0) / distancesA.length;
console.log(averageDistance)