import {Component} from "react"; export default class ScoreStats extends Component { constructor(params) { super(params); } getAverage(values) { return values.reduce((p, c) => p + c, 0) / values.length; } render() { const data = this.props.data; return
{data.percentage}
{data.currentScore.toLocaleString()}
Average Cut
{this.getAverage(data.leftHand.averagePreSwing).toFixed(2)}
{this.getAverage(data.leftHand.averagePostSwing).toFixed(2)}
{this.getAverage(data.leftHand.averageCut).toFixed(2)}
{this.getAverage(data.rightHand.averagePreSwing).toFixed(2)}
{this.getAverage(data.rightHand.averagePostSwing).toFixed(2)}
{this.getAverage(data.rightHand.averageCut).toFixed(2)}