I haven't done Javascript in years and I'm trying to get back into it. I just wanted to create a couple random numbers and add them together. I also wanted to practice using "getVariable()" to protect manipulation of the original variable while making them accessible to the entire script. I must be remembering this wrong or I'm doing something really stupid. I keeping getting a message that getScore1 is undefined. I tried writing it as function getScore1() and this.getScore1 = function(){}. Can someone please point me in the correct direction?
function twoRandomScores(){
var score1 = Math.random(1, 10);
var score2 = Math.random(1, 10);
return score1 + score2;
this.getScore1 = function(){
return this.score1;
}
function getScore2(){
return this.score2;
}
}
document.write(getScore1() + '+' + getScore2() + '=' + twoRandomScores());