title: JavaScript function returning "undefined"
body: <p>I wrote a simple code to choose random name from four, using "random_word();" function and it doesn't work. It says:"undefined". Can anyone explain me why and help to fix it? Thanks for all help.</p>
  
  <pre><code>var randomWord;
  
  var word = new Array(3);
  word[0] = "Michael";
  word[1] = "Simon";
  word[2] = "Peter";
  word[3] = "Mark";
  
  function random_word(){
  var randomWord = word[Math.floor(Math.random()*word.length)]
  }
  
  random_word();
  
  document.write(randomWord);
  </code></pre>