title: how can i use an input from html form in my javascript function?
body: <p>Am new to js and would like to use values from an input in my js 'if' code. I wrote the code below but it does not render. Can you tell me what i did wrong.</p>
  
  <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 myFunction() {
    var age = document.getElementById('selection').value;
     if (age &lt; 4) {
      alert('The child is too young');
      } else if (age &gt; 40) {
          alert('You are too old for this course');
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form onsubmit=" myFunction()"&gt;
      Age: &lt;input type="text" id="selection" name="age"&gt;
      &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>