--- id: 6437133052eaf04d7300e622 title: Step 22 challengeType: 0 dashedName: step-22 --- # --description-- Declare an `average` function which takes an array of numbers as the `nums` parameter. It should return the average of all the numbers in the array. The average can be calculated by dividing the sum of all the numbers in the array by the length of the array. Remember that you have a `sum` function you can use. # --hints-- You should declare an `average` variable. ```js assert.match(code, /(?:let|const|var)\s+average/); ``` You should use `const` to declare your `average` variable. ```js assert.match(code, /const\s+average/); ``` Your `average` variable should be a function. ```js assert.isFunction(average); ``` Your `average` function should use arrow syntax. ```js assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. ```js assert.equal(average([1,2,3]), 2); assert.equal(average([1,2,3,4,5]), 3); ``` # --seed-- ## --seed-contents-- ```html