Lesson 12 Learning construction Step 3 Completed code

by nathanesa

JavaScript

// functions
function getGoldCoins() {
  return Math.floor(Math.random() * 19) + 2;
}


// start of the game
document.write('You walk into the cave<br>');
document.write('You reach into the pouch...<br>');
var coins = getGoldCoins();
document.write('You find ' + coins + ' gold coins!');