19.09.2022, 11:49
So funktioniert es:
Code:
let min = 0;
let max = 100;
let x_arr = [];
let y_arr = [];
let z_arr = [];
for (let i = 0; i < 1440; i++) {
var r = Math.round(Math.random() * (max - min)) + min;
x_arr[i]= i;
y_arr[i]= r;
z_arr.push([x_arr[i], y_arr[i]]);
}
s_arr = y_arr.sort(function(a, b){return a - b});
document.write("x " + x_arr + '<hr>');
document.write("y " + y_arr + '<hr>');
document.write("s " + s_arr + '<hr>');
document.write("z " + z_arr + '<hr>');
console.log(s_arr);
console.log(z_arr);
let neu_arr = [];
let zz_arr = [];
for (let i = 0; i < 1440; i++) {
neu_arr[i]= i;
zz_arr.push([neu_arr[i], s_arr[i]]);
}
document.write("zz " + zz_arr + '<hr>');
console.log(zz_arr);