JSFiddle - React, Tailwind, and code Playground
JavaScript
var getScore1, getScore2, sum; // define global variables
function randomScore() {
var score1 = Math.random() * 10,
score2 = Math.random() * 10;
getScore1 = function() {
return score1;
}
getScore2 = function() {
return score2;
}
return score1 + score2;
}
sum = randomScore();
console.log(getScore1() + '+' + getScore2() + '=' + sum);