19
loading...
This website collects cookies to deliver better user experience
any
in TypescriptPropTypes.shape
instead of PropTypes.object
PropTypes.arrayOf
instea_d of PropTypes.array
const numbers = [27, 52, 28, 122, 67];
// Example 1
const average = arr => arr.reduce((a, b) => a + b) / arr.length
console.log(average(numbers));
// => 59.2
// Example 2
const anotherAverage = arr => {
const sum = arr.reduce((partialSum, nextNumber) => partialSum + nextNumber, 0);
return sum / arr.length;
}
console.log(anotherAverage(numbers));
// => 59.2