Hello All I have array & i need to perform various operation like sum, total, average. All these 3 are achieved, Now I need to find the minimum & maximum value in array. I am stucked on this below is the code.
Below is TS Part
people: Array<number> = [1, 2, 3, 4, 5];
total: number = 0;
arrayLength: number = this.people.length;
average: number = 0;
sum() {
for (var i in this.people) { this.total += this.people[i]; }
}
ngOnInit() {
this.sum();
this.average = (this.total / this.arrayLength);
}
Below is HTML Part
<span *ngFor="let p of people" style="font-size:18px">{{p}} </span><br><br>
<button >Quantity</button> = {{arrayLength}}<Br><br>
<button >Average</button> = {{average}}<Br><br>
<button >Sum</button> <span *ngIf="sumShow"> = {{total}}</span><Br><br>