title: How to write a Javascript function inside the functions.php of Wordpress?
body: <p>I'm altering a plugin on developer recommendations (<a href="http://premium.wpmudev.org/forums/topic/appointments-service-categories" rel="nofollow noreferrer">See latest post</a>), which advices to write a bit of Javascript in the <code>functions.php</code> of Wordpress.</p>
  
  <p>Now, when I did that my whole wordpress went blank. Well, after a bit of thinking.. "You can't write plain Javascript inside of PHP"..</p>
  
  <p>So I wrote them inside a <code>&lt;script&gt;</code> tag, and that inside of a <code>echo "</code>, <code>";</code> tags. Now.. I'm unsure of the function working (have not tested that yet), but Wordpress is showing again, but.. I'm getting the message </p>
  
  <blockquote>
    <p>Notice: Undefined variable: group in /home/appelhulp/domains/appelhulp.nl/public_html/wp-content/themes/Divi/functions.php on line 8<br>
    Notice: Undefined variable: option in /home/appelhulp/domains/appelhulp.nl/public_html/wp-content/themes/Divi/functions.php on line 9<br>
    Notice: Undefined variable: option in /home/appelhulp/domains/appelhulp.nl/public_html/wp-content/themes/Divi/functions.php on line 25</p>
  </blockquote>
  
  <p>And this is the code file 
  <img src="https://i.stack.imgur.com/L0u0T.png" alt="enter image description here"></p>
  
  <p><strong>So my question:</strong><br>
  What is the problem and how do I make those messages disappear? </p>
  
  <h1>The correct answer</h1>
  
  <p>Although I accepted @Burak's answer, this is only half of the correct answer. Please also see @RahilWazir's part, which half of his/her answer belongs to the solution. As Burak came with the correct script, RahilWazir came with the suggestion to place it in the <code>footer.php</code> instead of <code>functions.php</code>. And placing it there, did the trick. In <code>functions.php</code> didn't let me achieve what I was seeking. Therefor, thanks both!</p>