showing results for - "functions call functions js"
Bastian
01 Sep 2020
1/*
2Write a function sum that takes an array of numbers and 
3returns the sum of these numbers. 
4Write a function mean that takes an array of numbers and 
5returns the average of these numbers. 
6The mean function should use the sum function.
7*/
8function sum (arr) {
9    let suma = 0;
10    for (let i = 0; i < arr.length; i++) {
11        
12        let num= parseInt(arr[i]);
13        suma += num;
14    }
15    return suma;
16  }
17  
18  function mean (arr) {
19    let average = sum(arr) /arr.length;
20    
21    return average;
22  }