title: Find smallest & largest element in Array Angular & Typescript
body: <p>Hello All I have array &amp; i need to perform various operation like sum, total, average. All these 3 are achieved, Now I need to find the minimum &amp; maximum value in array. I am stucked on this below is the code.</p>
  
  <p>Below is TS Part</p>
  
  <pre><code>people: Array&lt;number&gt; = [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);
    }
  </code></pre>
  
  <p>Below is HTML  Part</p>
  
  <pre><code>&lt;span *ngFor="let p of people" style="font-size:18px"&gt;{{p}} &lt;/span&gt;&lt;br&gt;&lt;br&gt;
  &lt;button &gt;Quantity&lt;/button&gt; = {{arrayLength}}&lt;Br&gt;&lt;br&gt;
  &lt;button &gt;Average&lt;/button&gt; = {{average}}&lt;Br&gt;&lt;br&gt;
  &lt;button &gt;Sum&lt;/button&gt; &lt;span *ngIf="sumShow"&gt; = {{total}}&lt;/span&gt;&lt;Br&gt;&lt;br&gt;
  </code></pre>