input: Write a function that generates a basic HTML form using JavaScript to submit a user's name. The form should prevent the default form submission and send the form data (name) to the server in JSON format using the Fetch API.
  
  ### Function Signature:
  html
  <form id="myForm" onsubmit="submitForm(event)">
    Name:<br>
    <input type="text" name="name"><br>
    <input type="submit">
  </form>
  
  <script>
  function submitForm(event) {
    event.preventDefault();
  
    const form = document.getElementById('myForm');
    const name = form.querySelector('input[name="name"]').value;
  
    const data = { name: name };
  
    const options = {
      method: 'POST',
      body: JSON.stringify(data),
      headers: {
        'Content-Type': 'application/json'
      }
    };
  
    fetch('/my-api/submit-form', options)
      .then(response => response.json())
      .then(data => {
        console.log(data);
      });
  }
  </script>
  
  
  ### Assertions:
  html
  <!DOCTYPE html>
  <html>
  <head>
    <title>Test Form</title>
  </head>
  <body>
    <form id="myForm" onsubmit="submitForm(event)">
      Name:<br>
      <input type="text" name="name" value="John"><br>
      <input type="submit">
    </form>
  
    <script>
    function submitForm(event) {
      event.preventDefault();
  
      const form = document.getElementById('myForm');
      const name = form.querySelector('input[name="name"]').value;
  
      const data = { name: name };
  
      const options = {
        method: 'POST',
        body: JSON.stringify(data),
        headers: {
          'Content-Type': 'application/json'
        }
      };
  
      fetch('/my-api/submit-form', options)
        .then(response => response.json())
        .then(data => {
          console.assert(typeof data === 'object', 'Data should be an object');
          console.assert(data.name === 'John', 'Name should be John');
        });
    }
    </script>
  </body>
  </html>
  
  
  ### Expected Output:
  The form should prevent the default submission and send the name "John" to the server in JSON format. The server response should be checked to ensure it is an object and the name is "John".
output: javascript
  function submitForm(event) {
    event.preventDefault();
  
    const form = document.getElementById('myForm');
    const name = form.querySelector('input[name="name"]').value;
  
    const data = { name: name };
  
    const options = {
      method: 'POST',
      body: JSON.stringify(data),
      headers: {
        'Content-Type': 'application/json'
      }
    };
  
    fetch('/my-api/submit-form', options)
      .then(response => response.json())
      .then(data => {
        console.log(data);
      });
  }
  