In this section, we'll be working in the kmeans.js file. The first thing to do is to add our functions for mean and distance to the top of the file. Since these are generic functions that can be called statistically, we will not define them inside a class. Add the following to the top of the file:
/** * Calculate the mean of an array of numbers. * @param {Array.<number>} numbers * @return {number} */const mean = numbers => numbers.reduce((sum, val) => sum + val, 0) / numbers.length;/** * Calculate the distance between two points. * Points must be given as arrays or objects with equivalent keys. * @param {Array.<number>} a * @param {Array.<number>} b * @return {number} */const distance = (a, b) => Math.sqrt( a.