title: Uncaught ReferenceError: function is not defined
body: <p>I try to display a popup when I click on a button using javascript.
  But this error appears :</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: confirmation is not defined
        at HTMLButtonElement.onclick</p>
  </blockquote>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function confirmation() {
    var answer = confirm("Leave tizag.com?")
    if (answer) {
      alert("Bye bye!")
      window.location = "http://www.google.com/";
    } else {
      alert("Thanks for sticking around!")
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button type="submit" class="danger btn btn-danger" onclick="confirmation()"&gt;Transférer&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>