Lesson 12 Learning construction Step 3 Solution
by nathanesa
JavaScript
// functions
function getGoldCoins() {
return Math.floor(Math.random() * 21) + 10;
}
function getSilverCoins() {
return Math.floor(Math.random() * 101);
}
// start of the game
document.write('You walk into the cave<br>');
document.write('You reach into the pouch...<br>');
var gold = getGoldCoins();
var silver = getSilverCoins();
document.write('You find ' + gold + ' gold coins and ' + silver + ' silver coins!');