I'm new to javascript and am having trouble with a counting program and I believe it could be trouble with variable scope.
var count = 0; {
function gimmeRandom() {
var rand = Math.floor(Math.random() * 10) + 1;
count++;
}
function countToRandom() {
for (count = 1; count <= rand; count++) {
console.log(count);
}
}
console.log("Counting to a random number");
gimmeRandom();
countToRandom();
console.log("Counting to another random number");
gimmeRandom();
countToRandom();
console.log("There has been " + count + " random numbers used");
}