Script And Friends logo

Modules 07


// file-1.js
const sum = (x, y) = > x + y;
const square = x = > x * x;
const mean = data = > data.reduce( sum)/ data.length;
export default sum;

Let us assume that there is a file file-2.js in the same directory as file-1.js. Import the function sum from file-1.js into file-2.js by using the ES6 syntax.