A quick function to return random football scores with realistic score probabilities.
In your desired console run:
npm i match-simulation-algorithm
In your js file require the package by writing:
const matchSim = require('match-simulation-algorithm');Call the getScore() function like so (must be assigned to a variable):
const result = matchSim.getScore();returns an object with two variables: homeScore and awayScore
Example output:
{ homeScore: 3, awayScore: 2 }These can be accessed like so:
const homeScore = result.homeScore;
const awayScore = result.awayScore;