title: Javascript: function does not activate onClick
body: <p>New on JS. </p>
  
  <p>I'm following a tutorial. </p>
  
  <p>I've a function that ask for your name and prints:</p>
  
  <p>"Hi ("name"), today is: "actual date"".</p>
  
  <p>My function works great if just put in the js file. </p>
  
  <p>But going beyond the tutorial, when experimenting with "onclick" on a button, the functions is not lunched. </p>
  
  <p>So far: </p>
  
  <p>1.- The functions is well structurated.<br>
  2.- HTML onclick lunches any "alert();" message, but the one calling my function. Just a prompt asking for your name is lunched. </p>
  
  <p>I've searched Google and here. </p>
  
  <p><a href="https://stackoverflow.com/questions/15619627/javascript-function-will-not-activate-onclick]">Javascript function will not activate onClick</a><a href="http://jsfiddle.net/OmarGon/mxe6ke1j/" rel="nofollow noreferrer">1</a> (but this is not my case, since my function do work).</p>
  
  <p>JSFIDDLE: </p>
  
  <p><a href="http://jsfiddle.net/OmarGon/mxe6ke1j/" rel="nofollow noreferrer">jsfiddle</a></p>
  
  <p>Here is my code:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;section&gt;     
       &lt;button onclick="alert(messageParts.join(''));"&gt;Click to enter your name!&lt;/button&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function getMonthName(index) {
  var months = ["January", "February", "March",
               "April", "May", "June", "July", "August",
               "September", "October", "November", "December"];
  
  return months[index];
  
  }
  
  
  
  function abbrName(text) {
      return text.substr(0,3);
  }
  
  
  
  var date = new Date();
  
  
  var messageParts = [
      "Hello, ",
      prompt("Please, enter your name","Please, enter your name"),
      ". Today is ",
      date.getDate(),
      " ",
      abbrName(getMonthName(date.getMonth())),
      " ",
      ", ",
      date.getFullYear()
  
  ];
  </code></pre>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>1.- I think i have to use 'comillas simples' when calling a functions with "" in the outside. Now my function works, but not 100% as wished:</p>
  
  <p>1.1.- The prompt is launched when page loads, when it should be launched when clicking the button. </p>
  
  <p>1.2.-You have to enter a name when the prompt is launched, because it's not launched anymore.</p>