I'm currently developing an Angular 4 application and facing an issue with a function I'm trying to write. The goal is to extract the minimum and maximum numbers from three array objects. The yAxisData object consists of three yaxis array objects. However, the current function I have doesn't seem to give me the minimum number from the arrays. I can see that three array objects are being passed to the getMinY method.
export interface YAxisData {
yaxis: number[];
}
yAxisData: Array < YAxisData > = [];
ngOnInit() {
this.addSeries();
let minY = this.getMinY(this.yAxisData);
}
private addSeries() {
this.results.forEach(element => {
if (element.data != null)
this.yAxisData.push({
yaxis: element.yaxis
});
});
}
private getMinY(data: any[]) {
return data.reduce((min, p) => p < min ? p : min, data);
}