title: Passing string parameter in JavaScript function
body: <p>I was trying to pass a string to a JavaScript function.</p>
  <p>As it's mentioned here - <em><a href="https://stackoverflow.com/questions/9643311/pass-a-string-parameter-in-an-onclick-function">Pass a string parameter in an onclick function</a></em></p>
  <p>I'm using this simple code-</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;body&gt;
          &lt;script&gt;
              name = &quot;Mathew&quot;;
              document.write(&quot;&lt;button id='button' type='button' onclick='myfunction(\''&quot; + name + &quot;'\')'&gt;click&lt;/button&gt;&quot;)
  
              function myfunction(name)
              {
                  alert(name);
              }
          &lt;/script&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>But in the console it's giving an error like <code>Uncaught SyntaxError: Unexpected token }</code>.</p>