How do I extract form data in html with js

I’m trying to create a web app, and I need to know the user input from form.

<form action="" method="get" class="settings">
    <div class="settings">
      <label for="length">length of character(s): </label>
      <input type="number" name="length" id="length" placeholder="5" required>
      <input type="submit" value="Change">
    </div>
  </form>

I need the form to run a js func foo()
so I assume that I need to put it

<form action="" method="get" class="settings">
              ↑

how do I get the value of id=”length” and use it in form action"foo()"?